![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
At any rate statistics for such indexes are collected (look for rows in pg_stats that belong to the index), and these statistice are exactly the same as would be collected for the redundant column, so why should there be a difference? |
#12
| |||
| |||
|
|
At any rate statistics for such indexes are collected (look for rows in pg_stats that belong to the index), and these statistice are exactly the same as would be collected for the redundant column, so why should there be a difference? The problem is in the histograms, which are collected per column, not per index. You don't have histograms on lower(col1) unless it's in a separate column. |
#13
| |||
| |||
|
|
Why do you claim that without a test? This is PostgreSQL 9.1: CREATE TABLE test(id serial primary key, val varchar(20) NOT NULL); DO $$BEGIN FOR i IN 1..10000 LOOP INSERT INTO test(val) VALUES (substr(random()::text, 3)); END LOOP; END;$$; CREATE INDEX test_val_ind ON test(lower(val)); SHOW default_statistics_target; default_statistics_target --------------------------- 100 (1 row) ANALYZE test; SELECT array_length(histogram_bounds, 1) FROM pg_stats WHERE tablename = 'test_val_ind'; array_length -------------- 101 (1 row) Yours, Laurenz Albe |
#14
| |||
| |||
|
|
CREATE TABLE test(id serial primary key, val varchar(20) NOT NULL); CREATE INDEX test_val_ind ON test(lower(val)); SELECT array_length(histogram_bounds, 1) FROM pg_stats WHERE tablename = 'test_val_ind'; array_length -------------- 101 (1 row) I don't understand? What does this prove? That there is a histogram on lower(val)? How does your example prove that? |
#15
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |