pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: 2 million queries against a table
Date: Wed, 15 Jul 2020 10:28:18 -0500
Message-ID: <b6f93099-9c28-58ea-4f70-46b9ca42ade2@gmail.com> (raw)
In-Reply-To: <CAEP=qeOSNniLWhCKkyU774xFH9feQ=SKsuB-zoXthxdMj5GtKw@mail.gmail.com>
References: <CAEP=qeOSNniLWhCKkyU774xFH9feQ=SKsuB-zoXthxdMj5GtKw@mail.gmail.com>

On 7/15/20 10:10 AM, Adam Sanchez wrote:
> Hi
>
> I need to run 2 million queries against a three columns table t
> (s,p,o) which size is 10 billions rows. The data type of each column
> is string.  The server has 512G RAM, 32 cores and 14T SSD (RAID 0)
>
> Only two types of queries:
>
> select s p o from t where s = param
> select s p o from t where o = param

What's the index cardinality of "s" and "o" (about how many records per key)?

What kind of indexes do you have on them?  Is the table clustered on one of 
the keys?

What version of Postgresql?

> If I store the table in a Postgresql database takes 6 hours using a
> Java ThreadPoolExecutor.

How many threads?

What values of:
shared_buffers
temp_buffers
work_mem

> Do you think Postgresql itself can speed up the queries processing
> even more? What would be the best strategy?

2M queries in 6 hours is 93 queries/second.  Over 32 cores, that's only 
three per second.   Not very much.

> These are my ideas:
>
> 1. Use Spark to launch queries against the table (extracted from
> Postgresql) loaded in a dataframe
> 2. Use PG-Strom, an extension module of PostgreSQL with GPU support
> and launch the queries against the table.
>
>
> Any suggestion will be appreciated

IO is -- as usual -- the bottleneck, followed closely by cache efficiency.  
Are you issuing the queries in a random order, or sequentially by key (which 
would enhance cache efficiency)?

-- 
Angular momentum makes the world go 'round.





view thread (4+ messages)  latest in thread

Message-ID: <b6f93099-9c28-58ea-4f70-46b9ca42ade2@gmail.com>
Permalink:  ../b6f93099-9c28-58ea-4f70-46b9ca42ade2@gmail.com/
Also on:    postgresql.org/message-id/b6f93099-9c28-58ea-4f70-46b9ca42ade2@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: 2 million queries against a table
  In-Reply-To: <b6f93099-9c28-58ea-4f70-46b9ca42ade2@gmail.com>
  References: <CAEP=qeOSNniLWhCKkyU774xFH9feQ=SKsuB-zoXthxdMj5GtKw@mail.gmail.com> <b6f93099-9c28-58ea-4f70-46b9ca42ade2@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox