Re: [HACKERS] having and union in v7beta
От | Tom Lane |
---|---|
Тема | Re: [HACKERS] having and union in v7beta |
Дата | |
Msg-id | 27055.951783375@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: [HACKERS] having and union in v7beta (Jose Soares <jose@sferacarta.com>) |
Список | pgsql-hackers |
Jose Soares <jose@sferacarta.com> writes: >>>> SELECT ... UNION (is 3 / 4 times slow) >> >> Can't help you on that without more details, either. What is the >> query exactly, what plan does EXPLAIN show, and what plan did you >> get from 6.5? > psql7=> EXPLAIN select distretto from comuni union select codice_fiscale from comuni; > NOTICE: QUERY PLAN: > Unique (cost=1767.19..1808.90 rows=1668 width=12) -> Sort (cost=1767.19..1767.19 rows=16684 width=12) -> Append (cost=0.00..464.84 rows=16684 width=12) -> Seq Scan on comuni (cost=0.00..232.42 rows=8342 width=12) -> Seq Scan on comuni (cost=0.00..232.42 rows=8342 width=12) > [ and exactly the same plan for 6.5 ] OK, so much for my first thought that the 7.0 planner was choosing a bad plan. One relevant change is that Unique nodes now invoke the proper type-specific equality function(s) to decide whether tuples are distinct or not, instead of doing a bitwise comparison (memcmp()) like they did before. But it's tough to believe that that accounts for a 3-to-4x slowdown of this query; certainly I don't see much performance difference on the datatypes I tried. What datatypes are your fields, anyway? The other possibility is that the Sort step is a lot slower in 7.0, although I don't think it should be. Are you running both versions with the same -S setting, and if so what is it? Could it be that the query is right on the edge of needing to switch from memory-based to disk-based sort? Perhaps 7.0 is deciding that it needs to go to disk a little sooner than 6.5 did. regards, tom lane
В списке pgsql-hackers по дате отправления: