pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
2 million queries against a table
4+ messages / 4 participants
[nested] [flat]

* 2 million queries against a table
@ 2020-07-15 15:10 Adam Sanchez <a.sanchez75@gmail.com>
  2020-07-15 15:28 ` Re: 2 million queries against a table Ron <ronljohnsonjr@gmail.com>
  2020-07-15 15:38 ` Re: 2 million queries against a table Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 4+ messages in thread

From: Adam Sanchez @ 2020-07-15 15:10 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

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

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

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

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

Best,





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: 2 million queries against a table
  2020-07-15 15:10 2 million queries against a table Adam Sanchez <a.sanchez75@gmail.com>
@ 2020-07-15 15:28 ` Ron <ronljohnsonjr@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Ron @ 2020-07-15 15:28 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

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.





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: 2 million queries against a table
  2020-07-15 15:10 2 million queries against a table Adam Sanchez <a.sanchez75@gmail.com>
@ 2020-07-15 15:38 ` Tom Lane <tgl@sss.pgh.pa.us>
  2020-07-15 15:55   ` Re: 2 million queries against a table Rob Sargent <robjsargent@gmail.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Tom Lane @ 2020-07-15 15:38 UTC (permalink / raw)
  To: Adam Sanchez <a.sanchez75@gmail.com>; +Cc: pgsql-general@lists.postgresql.org

Adam Sanchez <a.sanchez75@gmail.com> writes:
> 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

TBH, this is a pretty silly way to use a SQL database.  Put
the probe values into a temporary table (in batches, perhaps)
and do a join.  The per-row cost of that sort of approach
will be multiple orders of magnitude smaller than a query
per row.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: 2 million queries against a table
  2020-07-15 15:10 2 million queries against a table Adam Sanchez <a.sanchez75@gmail.com>
  2020-07-15 15:38 ` Re: 2 million queries against a table Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-07-15 15:55   ` Rob Sargent <robjsargent@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Rob Sargent @ 2020-07-15 15:55 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org



On 7/15/20 9:38 AM, Tom Lane wrote:
> Adam Sanchez <a.sanchez75@gmail.com> writes:
>> 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
> 
> TBH, this is a pretty silly way to use a SQL database.  Put
> the probe values into a temporary table (in batches, perhaps)
> and do a join.  The per-row cost of that sort of approach
> will be multiple orders of magnitude smaller than a query
> per row.
> 
> 			regards, tom lane
> 
> 
I had assumed the OP was planning a performance test for say 2M separate 
user/requests (perhaps non-unique) rather than asking for the specific 
2M records.






^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2020-07-15 15:55 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 15:10 2 million queries against a table Adam Sanchez <a.sanchez75@gmail.com>
2020-07-15 15:28 ` Ron <ronljohnsonjr@gmail.com>
2020-07-15 15:38 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-07-15 15:55   ` Rob Sargent <robjsargent@gmail.com>

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