Re: Query slow for new participants - Mailing list pgsql-performance

From Laurenz Albe
Subject Re: Query slow for new participants
Date
Msg-id 38d1ac81dfb700d154290aa35f513320d9fd093e.camel@cybertec.at
Whole thread Raw
In response to Re: Query slow for new participants  ("support@mekong.be" <support@mekong.be>)
List pgsql-performance
support@mekong.be wrote:
> EXPLAIN (ANALYZE, BUFFERS), not just EXPLAIN
> "Index Scan using ix_companyarticledb_company on companyarticledb  (cost=0.57..2.80 rows=1 width=193) (actual
time=1011.335..1011.454rows=1 loops=1)"
 
> "  Index Cond: (companyid = 77)"
> "  Filter: (articleid = 7869071)"
> "  Rows Removed by Filter: 2674361"
> "  Buffers: shared hit=30287"
> "Planning time: 0.220 ms"
> "Execution time: 1011.502 ms"

Your problem are the "Rows Removed by Filter: 2674361".

The first thing I would try is:

  ALTER TABLE public.companyarticledb
     ALTER companyid SET STATISTICS 1000;

  ALTER TABLE public.companyarticledb
     ALTER articleid SET STATISTICS 1000;

  ANALYZE public.companyarticledb;

Then PostgreSQL has a better idea which condition is selective.

You can set STATISTICS up to 10000, but don't forget that high values
make ANALYZE and planning slower.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com



pgsql-performance by date:

Previous
From: "support@mekong.be"
Date:
Subject: Re: Query slow for new participants
Next
From: Fd Habash
Date:
Subject: What is pg_stat_user_tables Showing NULL for last_autoanalyze &last_autovacuum