Re: INDEX suggestion needed
От | Manfred Koizar |
---|---|
Тема | Re: INDEX suggestion needed |
Дата | |
Msg-id | ja5kvuo09052ldtp94maadc7shmhr5vg6t@4ax.com обсуждение исходный текст |
Ответ на | Re: INDEX suggestion needed (Alvaro Herrera <alvherre@dcc.uchile.cl>) |
Ответы |
Re: INDEX suggestion needed
Re: INDEX suggestion needed |
Список | pgsql-general |
On Fri, 13 Dec 2002 13:00:14 -0300, Alvaro Herrera <alvherre@dcc.uchile.cl> wrote: >Now this catched my attention (in the questions' side, sorry, not the >answers'). Why the aggregate takes 10 times the time needed for the >indexscan? Good point! > One would think that a function like count() should be >pretty cheap, COUNT is cheap. But COUNT(DISTINCT something) is not trivial, it has to keep a list of all values it has already counted. I didn't look at the implementation. Do we have O(n^2) cost here? Thomas, could you EXPLAIN ANALYZE some test cases with SELECT COUNT(*) FROM ( SELECT DISTINCT a_id FROM stat_pages WHERE ... ) AS x; and compare them to the results of SELECT COUNT(DISTINCT ...)? So now you are back where you started. At least you have an index on "visit" now ;-) Servus Manfred
В списке pgsql-general по дате отправления: