Re: Conundrum with scaling out of bottleneck with hot standby, PgPool-II, etc.

2020-12-23 Thread Marco Colli
that slave nodes you only scale the *read* throughput. Hope it helps, Marco Colli

Re: Index for range queries on JSON (user defined fields)

2020-12-05 Thread Marco Colli
PM Nick Cleaton wrote: > On Fri, 4 Dec 2020 at 15:39, Marco Colli wrote: > >> Hello! >> >> We have a multi-tenant service where each customer has millions of users >> (total: ~150M rows). Now we would like to let each customer define some >> custom columns for

Index for range queries on JSON (user defined fields)

2020-12-04 Thread Marco Colli
dex-wildcard/). Are there any plans to add support for range queries to GIN indexes (on JSON) in the future versions of PostgreSQL? Marco Colli Pushpad

Re: Statistics on array values

2020-02-02 Thread Marco Colli
thousands to a few millions of rows and each project has its own tags that the customer can define (unlimited tags for each row, but usually only 1 - 10 actually used) Il Dom 2 Feb 2020, 19:32 Tom Lane ha scritto: > Marco Colli writes: > > Unfortunately I don't get actual improve

Re: Statistics on array values

2020-02-02 Thread Marco Colli
? On Sun, Feb 2, 2020 at 6:11 PM Tom Lane wrote: > Marco Colli writes: > > 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 >

Re: Statistics on array values

2020-02-02 Thread Marco Colli
zby wrote: > On Sun, Feb 02, 2020 at 03:18:19PM +0100, Marco Colli wrote: > > 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 &quo

Statistics on array values

2020-02-02 Thread Marco Colli
s... 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

Re: Bad query plan when you add many OR conditions

2020-01-10 Thread Marco Colli
ws on disk... It cannot take ~1 minute to access a few rows on disk (max 30 rows, actual 0 rows). On Fri, Jan 10, 2020 at 4:18 PM Tom Lane wrote: > Marco Colli writes: > > As you can see it is a *index scan* and not an *index only* scan... I > don't > > understand why.

Re: Bad query plan when you add many OR conditions

2020-01-10 Thread Marco Colli
y the query... so an index only scan should be possible. On Fri, Jan 10, 2020 at 2:34 PM Justin Pryzby wrote: > On Fri, Jan 10, 2020 at 12:03:39PM +0100, Marco Colli wrote: > > I have added this index which would allow an index only scan: > > "index_subscriptions_on_project_i

Re: Bad query plan when you add many OR conditions

2020-01-10 Thread Marco Colli
ll on array fields like tags??). On Fri, Jan 10, 2020 at 4:06 AM Justin Pryzby wrote: > On Fri, Jan 10, 2020 at 02:11:14AM +0100, Marco Colli wrote: > > I have a query on a large table that is very fast (0s): > > > https://gist.github.com/collimarco/039412b4fe0dcf39955888f96eff2

Re: Bad query plan when you add many OR conditions

2020-01-10 Thread Marco Colli
eated_at DESC) On Fri, Jan 10, 2020 at 4:06 AM Justin Pryzby wrote: > On Fri, Jan 10, 2020 at 02:11:14AM +0100, Marco Colli wrote: > > I have a query on a large table that is very fast (0s): > > > https://gist.github.com/collimarco/039412b4fe0dcf39955888f96eff29db#file-fast_que

Bad query plan when you add many OR conditions

2020-01-09 Thread Marco Colli
ry is generated dynamically by customers of a SaaS, so I don't have full control on it Thank you very much for any advice! Marco Colli

Re: Slow "not in array" operation

2019-11-13 Thread Marco Colli
Wow! Thank you very much Jeff!! I am really grateful. Thanks to the btree (instead of gin) the query now takes about 500ms instead of 70s. Il Mer 13 Nov 2019, 13:18 Jeff Janes ha scritto: > On Wed, Nov 13, 2019 at 6:56 AM Marco Colli > wrote: > >> > the answer is that is b

Re: Slow "not in array" operation

2019-11-13 Thread Marco Colli
e same index with BTree, because PG doesn't support BTree on array :( On Wed, Nov 13, 2019 at 12:30 PM Jeff Janes wrote: > On Wed, Nov 13, 2019 at 4:20 AM Marco Colli > wrote: > >> Replying to the previous questions: >> - work_mem = 64MB (there are hundreds of connections

Re: Slow "not in array" operation

2019-11-13 Thread Marco Colli
Replying to the previous questions: - work_mem = 64MB (there are hundreds of connections) - the project 123 has more than 7M records, and those that don't have the tag 'en' are 4.8M > What was the plan for the one that took 500ms? This is the query / plan without the filter on tags: SELECT COU

Re: Slow "not in array" operation

2019-11-12 Thread Marco Colli
HAVE the tag (~7s) 3. calculate [bitmap 1] - [bitmap 2] to find the subscriptions of the project that DON'T HAVE the tag On Tue, Nov 12, 2019 at 9:50 PM Tom Lane wrote: > Marco Colli writes: > > 3) Here's the query plan that I get after disabling the seq scan: > > >

Re: Slow "not in array" operation

2019-11-12 Thread Marco Colli
1) It is running on a DigitalOcean CPU-optimized droplet with dedicated hyperthreads (16 cores) and SSD. SHOW random_page_cost; => 2 2) What config names should I check exactly? I used some suggestions from the online PGTune, when I first configured the db some months ago: max_worker_processes = 1

Re: Slow "not in array" operation

2019-11-12 Thread Marco Colli
To be honest, I have simplified the question above. In order to show you the plan, I must show you the actual query, which is this: === QUERY === SELECT COUNT(*) FROM "subscriptions" WHERE "subscriptions"."project_id" = 123 AND "subscriptions"."trashed_at" IS NULL AND NOT (tags @> ARRAY['en']::va

Slow "not in array" operation

2019-11-12 Thread Marco Colli
7;t1' = ANY (tags)); How can I make the "not in array" operation fast? Any help would be appreciated, thank you! Marco Colli PostgreSQL 11 on Ubuntu 18LTS

Re: Extremely slow count (simple query, with index)

2019-08-22 Thread Marco Colli
I have completely solved (from 17s to 1s) by running this command: vacuum analyze subscriptions; Now I run the autovacuum more frequently using these settings in postgresql.conf: autovacuum_vacuum_scale_factor = 0.01 autovacuum_analyze_scale_factor = 0.01 Thanks to everyone - and in particular to

Extremely slow count (simple query, with index)

2019-08-22 Thread Marco Colli
Hello! Any help would be greatly appreciated. I need to run these simple queries on a table with millions of rows: ``` SELECT COUNT(*) FROM "subscriptions" WHERE "subscriptions"."project_id" = 123; ``` ``` SELECT COUNT(*) FROM "subscriptions" WHERE "subscriptions"."project_id" = 123 AND "subscri