Re: POC, WIP: OR-clause support for indexes

Поиск
Список
Период
Сортировка
От Andreas Karlsson
Тема Re: POC, WIP: OR-clause support for indexes
Дата
Msg-id 56EC9352.1080807@proxel.se
обсуждение исходный текст
Ответ на Re: POC, WIP: OR-clause support for indexes  (Teodor Sigaev <teodor@sigaev.ru>)
Список pgsql-hackers
I gave this patch a quick spin and noticed a strange query plan.

CREATE TABLE test (a int, b int, c int);
CREATE INDEX ON test USING gin (a, b, c);
INSERT INTO test SELECT i % 7, i % 9, i % 11 FROM generate_series(1, 
1000000) i;
EXPLAIN ANALYZE SELECT * FROM test WHERE (a = 3 OR b = 5) AND c = 2;
                                                            QUERY PLAN 


----------------------------------------------------------------------------------------------------------------------------------
BitmapHeap Scan on test  (cost=829.45..4892.10 rows=21819 width=12) 
 
(actual time=66.494..76.234 rows=21645 loops=1)   Recheck Cond: ((((a = 3) AND (c = 2)) OR ((b = 5) AND (c = 2))) AND 
(c = 2))   Heap Blocks: exact=5406   ->  Bitmap Index Scan on test_a_b_c_idx  (cost=0.00..824.00 
rows=2100 width=0) (actual time=65.272..65.272 rows=21645 loops=1)         Index Cond: ((((a = 3) AND (c = 2)) OR ((b =
5)AND (c = 2))) 
 
AND (c = 2)) Planning time: 0.200 ms Execution time: 77.206 ms
(7 rows)

Shouldn't the index condition just be "((a = 3) AND (c = 2)) OR ((b = 5) 
AND (c = 2))"?

Also when applying and reading the patch I noticed some minor 
issues/nitpick.

- I get whitespace warnings from git apply when I apply the patches.
- You have any insconstent style for casts: I think "(Node*)clause" 
should be "(Node *) clause".
- Same with pointers. "List* quals" should be "List *quals"
- I am personally not a fan of seeing the "isorderby == false && 
index->rd_amroutine->amcanorclause" clause twice. Feels like a risk for 
diverging code paths. But it could be that there is no clean alternative.

Andreas



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: flex: where's THIS been all this time?
Следующее
От: Kouhei Kaigai
Дата:
Сообщение: Re: WIP: Upper planner pathification