Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id EB7D313FA3D7 for ; Mon, 18 Jun 2012 13:49:53 -0300 (ADT) Received: from mail-gg0-f174.google.com ([209.85.161.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sgf9E-0005Hn-DH for pgsql-performance@postgresql.org; Mon, 18 Jun 2012 16:49:53 +0000 Received: by gglu4 with SMTP id u4so3853612ggl.19 for ; Mon, 18 Jun 2012 09:49:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=pzAbOgiJ1L+DTci/ZTvHHq+30IsCsMK8YhTSK6AgF9E=; b=XcPRk1eVynS1ZNuJ9OC2PzboBJUhWg9dCqEKUUyAhh9IlbhMBV6Kwr1J63289iucVx oYXrG5BfG78lwEBrVpNuJmJd7Q+jltJqC13geNFc4mR4CyMbshBlzPT6Zfyv/H3idmSi wsU7rnViYFotVimYzDzUJSSsTSJkjuZv+Vx2wSIY7vZPfa2eyOmS0vyyz2mry4VOTpFi H0p/9oqlTWyU05e1sr+esSV2NTyq+C2iUFV7tyLY3Uv8ePPag+oISHGOufJNutcyoUt4 f8CMcEZqWr+ixVygPImUK5dXENqRlKU1ozSthtAPnPH6vx1Xy66GLhPs4heaK+zvNHHe be/Q== MIME-Version: 1.0 Received: by 10.43.69.12 with SMTP id ya12mr5675338icb.50.1340038179168; Mon, 18 Jun 2012 09:49:39 -0700 (PDT) Received: by 10.50.87.40 with HTTP; Mon, 18 Jun 2012 09:49:39 -0700 (PDT) X-Originating-IP: [66.215.95.51] In-Reply-To: References: Date: Mon, 18 Jun 2012 09:49:39 -0700 Message-ID: Subject: Re: Expected performance of querying 5k records from 4 million records? From: Samuel Gendler To: Anish Kejariwal Cc: Jeff Janes , josh@agliodbs.com, pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=bcaec51d29c2a7a29f04c2c1f314 X-Gm-Message-State: ALoCoQlHG4F5xI3d4URf/iLw3XRTawsMPQrpQf1h15vsbyJTm6dCne5M7tUaRZvocsrClFB5wCUy X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201206/100 X-Sequence-Number: 47126 --bcaec51d29c2a7a29f04c2c1f314 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Jun 18, 2012 at 9:39 AM, Anish Kejariwal wrote: > > So, it looks like clustering the index appropriately fixes things! Also, > I'll recreate the index switching the order to (dataset_id, stat_id,data_id) > > Just keep in mind that clustering is a one-time operation. Inserts and updates will change the order of records in the table, so you'll need to re-cluster periodically to keep performance high if there are a lot of inserts and updates into the tables. I didn't re-read the thread, but I seem recall a partitioned table, so assuming you are partitioning in a manner which keeps the number of partitions that are actively being inserted/updated on to a minimum, you only need to cluster the active partitions, which isn't usually terribly painful. Also, if you are bulk loading data (and not creating random spaces in the table by deleting and updating), you can potentially order the data on the way into the table to avoid the need to cluster repeatedly. --sam --bcaec51d29c2a7a29f04c2c1f314 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Mon, Jun 18, 2012 at 9:39 AM, Anish Kejariwal <anishkej@gmail.com&= gt; wrote:

So, it looks like clustering the index appropriately fi= xes things! =A0Also, I'll recreate the index switching the order to (da= taset_id, stat_id,data_id)

Just keep in mind that clustering is a one= -time operation. =A0Inserts and updates will change the order of records in= the table, so you'll need to re-cluster periodically to keep performan= ce high if there are a lot of inserts and updates into the tables. I didn&#= 39;t re-read the thread, but I seem recall a partitioned table, so assuming= you are partitioning in a manner which keeps the number of partitions that= are actively being inserted/updated on to a minimum, you only need to clus= ter the active partitions, which isn't usually terribly painful. =A0Als= o, if you are bulk loading data (and not creating random spaces in the tabl= e by deleting and updating), you can potentially order the data on the way = into the table to avoid the need to cluster repeatedly.

--sam

--bcaec51d29c2a7a29f04c2c1f314--