Re: [PERFORM] query of partitioned object doesnt use index in qa

2017-09-15 Thread Tomas Vondra
On 09/16/2017 12:05 AM, Tom Lane wrote: > Andres Freund writes: >> I'm wondering if we should extend the new CREATE STATISTICS >> framework to be able to do that without requiring an index. > > I think that's already on the roadmap --- it's one of the reasons we > ended up with a SELECT-like syn

Re: [PERFORM] query of partitioned object doesnt use index in qa

2017-09-15 Thread Tom Lane
Andres Freund writes: > I'm wondering if we should extend the new CREATE STATISTICS framework to > be able to do that without requiring an index. I think that's already on the roadmap --- it's one of the reasons we ended up with a SELECT-like syntax for CREATE STATISTICS. But it didn't get done

Re: [PERFORM] query of partitioned object doesnt use index in qa

2017-09-15 Thread Andres Freund
On September 15, 2017 1:42:23 PM PDT, Tom Lane wrote: >One thing you could consider doing about this is creating an index >on (body ->> 'SID'::text), which would prompt ANALYZE to gather >statistics >about that expression. Even if the index weren't actually used in the >plan, this might improve

Re: [PERFORM] query of partitioned object doesnt use index in qa

2017-09-15 Thread Mike Broers
That makes a lot of sense, thanks for taking a look. An index like you suggest would probably further improve the query. Is that suggestion sidestepping the original problem that production is evaluating the landing_id bit with the partition index and qa is sequence scanning instead? AND exists

[PERFORM] Indexing an array of two separate columns

2017-09-15 Thread Jeremy Finzel
I have a user who is trying to match overlapping duplicate phone info but for different customer_ids. The intended conditional could be expressed: IF the intersection of the sets {c.main_phone, c.secondary_phone} and {c1.main_phone, c1.secondary_phone} is not empty THEN join EXCEPT where the inter

Re: [PERFORM] query of partitioned object doesnt use index in qa

2017-09-15 Thread Tom Lane
Mike Broers writes: > If Im reading this correctly postgres thinks the partition will return 6.5 > million matching rows but actually comes back with 162k. Is this a case > where something is wrong with the analyze job? You've got a lot of scans there that're using conditions like > │

Re: [PERFORM] query of partitioned object doesnt use index in qa

2017-09-15 Thread Mike Broers
Query finally came back with an explain analyze :) If Im reading this correctly postgres thinks the partition will return 6.5 million matching rows but actually comes back with 162k. Is this a case where something is wrong with the analyze job? Seq Scan on event__00071000 e_4 (cost=0.00..220437