Statistics on array values

Поиск
Список
Период
Сортировка
От Marco Colli
Тема Statistics on array values
Дата
Msg-id CAFvCgN4d9G6=u-_jJPBZhTSdf1Uqo+-txwWdAp_hCDKXbBQOHw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Statistics on array values  (Justin Pryzby <pryzby@telsasoft.com>)
Re: Statistics on array values  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
Hello!

Let's say that you have a simple query like the following on a large table (for a multi-tenant application):
SELECT "subscribers".* FROM "subscribers" WHERE "subscribers"."project_id" = 123 AND (tags @> ARRAY['de']::varchar[]);

If you run EXPLAIN ANALYZE you can see that stats are completely wrong. For example I get an expected count of 3,500 rows whereas the actual result is 20 rows. This also results in bad query plans...

In a previous discussion someone said that this wrong estimate is because @> uses a fixed selectivity of 0.001, **regardless of actual data**!!
Is that true? Is there any solution or any plan to improve this in future versions of PostgreSQL?

Finally it would be useful to have the ability to CREATE STATISTICS, to show PostgreSQL that there's a correlation between project_id and tag values... but this is a further step. Currently I can create statistics, however it seems to have no positive effect on the estimates for the above case


Marco Colli

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

Предыдущее
От: Duncan Whitham
Дата:
Сообщение: Re: Specific query taking time to process
Следующее
От: Justin Pryzby
Дата:
Сообщение: Re: Statistics on array values