X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EB55714B281F for ; Wed, 11 Aug 2004 20:46:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24965-03 for ; Wed, 11 Aug 2004 23:46:12 +0000 (GMT) Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) by svr1.postgresql.org (Postfix) with SMTP id 96EA414B2827 for ; Wed, 11 Aug 2004 20:46:10 -0300 (ADT) Received: (qmail 2630 invoked by uid 0); 12 Aug 2004 09:46:11 +1000 Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) (russell@pws.com.au@203.45.44.212) by mail.pws.com.au with SMTP; 12 Aug 2004 09:46:11 +1000 From: Russell Smith To: pgsql-performance@postgresql.org Subject: Re: Storing binary data. Date: Thu, 12 Aug 2004 09:44:56 +1000 User-Agent: KMail/1.6.1 References: <200408112042.50356.shridhar@frodo.hserus.net> In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200408120944.56155.mr-russ@pws.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200408/177 X-Sequence-Number: 7813 On Thu, 12 Aug 2004 02:29 am, Jesper Krogh wrote: > I gmane.comp.db.postgresql.performance, skrev Shridhar Daithankar: > > On Wednesday 11 Aug 2004 7:59 pm, Jesper Krogh wrote: > > > The "common" solution, I guess would be to store them in the filesystem > > > instead, but I like to have them just in the database it is nice clean > > > database and application design and if I can get PostgreSQL to "not > > > cache" them then it should be excactly as fast i assume. > > > > You can normalize them so that a table contains an id and a bytea column only. > > Te main table will contain all the other attributes and a mapping id. That > > way you will have only the main table cached. > > > > You don't have to go to filesystem for this, I hope. > > Further benchmarking. > > I tried to create a table with the excact same attributes but without > the binary attribute. It didn't change anything, so my idea that it > should be the binary-stuff that sloved it down was wrong. > > I have a timestamp column in the table that I sort on. Data is ordered > over the last 4 years and I select based on a timerange, I cannot make > the query-planner use the index on the timestamp by itself but if I "set > enable_seqscan = false" the query time drops by 1/3 (from 1.200 msec to > about 400 msec). > > I cannot figure out why the query-planner chooses wrong. > NB: It's postgresql 7.4.3 > Please post explain analyze of the query. I would guess you are using now() is your query, which is not optimized perfectly by the planner, so you end up with problems. But if you post explain analyze people will be able to tell you what the problem is. Maybe on with seqscan on, and one with it off. Regards Russell Smith