Re: [HACKERS] Postgres 6.5 beta2 and beta3 problem
От | Tom Lane |
---|---|
Тема | Re: [HACKERS] Postgres 6.5 beta2 and beta3 problem |
Дата | |
Msg-id | 29420.928948234@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: [HACKERS] Postgres 6.5 beta2 and beta3 problem (Daniel Kalchev <daniel@digsys.bg>) |
Ответы |
Re: [HACKERS] Postgres 6.5 beta2 and beta3 problem
|
Список | pgsql-hackers |
Daniel Kalchev <daniel@digsys.bg> writes: > The problem as it seems is that the restrictions to use indexes when > locale is enabled are not consistently applied - explain shows that > indices will be used, and the behavior with indexes and without > indexes is different (with indexes it's noticeably slower :-) so > indexes are apparently being used... Right, but what EXPLAIN doesn't show you (unless you can read the much uglier EXPLAIN VERBOSE output) is what index restrictions are being used. LIKE doesn't know anything about indexes, nor vice versa. What the index-scan machinery *does* know about is <, <=, etc. If you have WHERE clauses like "x >= 33" and "x <= 54" then an index scan knows to only scan the part of the index from 33 to 54. So you never even visit a large fraction of the table. This is why an index scan can be faster than a sequential scan even though the per-tuple overhead of consulting the index is larger. So, there is a special hack in the parser for LIKE (also for regexp matches): if the parser sees that the match pattern has a fixed initial substring, it inserts some >= and <= clauses that are designed to exploit what the index scanner can do. Our immediate problem is that we had to drop the <= clause in non-ASCII locales because it was wrong. So now an index scan driven by LIKE restrictions is not nearly as restrictive as it was, and has to visit many tuples (about half the table on average) whereas before it was likely to visit only a few, if you had a reasonably long fixed initial string. There are some other problems (notably, that the extra clauses are inserted even if there's no index and thus no way that they will be helpful) but those we know how to fix, and I hope to address them for 6.6. Fixing the <= problem requires knowledge about non-ASCII character sets, and I for one don't know enough to fix it... regards, tom lane
В списке pgsql-hackers по дате отправления: