pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Karthik Shivashankar <kshivashank@sandvine.com>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Improving performance of select query
Date: Mon, 14 Dec 2020 11:38:37 +0000
Message-ID: <20c57bfb287749c2a5ff22d7ddd3df93@sandvine.com> (raw)

Hi,

I have a postgres(v9.5) table named customer holding 1 billion rows. It is not partitioned but it has an index against the primary key (integer). I need to keep a very few records (say, about 10k rows) and remove everything else.

insert into customer_backup select * from customer where customer_id in (<id1>,<id2>,..);

If I go for something like above I'm afraid the insert-select may take a very long time as when I ran

select count(*) from customer;


it is taking about 45 minutes to return the count.

Are there ways to improve the efficiency of the insert-select by , say, tuning some configurations related to memory to improve the efficiency ?

This is a box with 96GB of RAM overall and I can stop all the data load and DML operations if needed.  But need a way to run this query as much efficiently as possible

Thanks and Regards,
Karthik

Disclaimer:
This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is considered confidential, proprietary, sensitive and/or otherwise legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation.

view thread (6+ messages)  latest in thread

Message-ID: <20c57bfb287749c2a5ff22d7ddd3df93@sandvine.com>
Permalink:  ../20c57bfb287749c2a5ff22d7ddd3df93@sandvine.com/
Also on:    postgresql.org/message-id/20c57bfb287749c2a5ff22d7ddd3df93@sandvine.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: kshivashank@sandvine.com
  Subject: Re: Improving performance of select query
  In-Reply-To: <20c57bfb287749c2a5ff22d7ddd3df93@sandvine.com>
  References: <20c57bfb287749c2a5ff22d7ddd3df93@sandvine.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