Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 9E1DD650E8E for ; Tue, 24 Jun 2008 06:33:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 41177-10 for ; Tue, 24 Jun 2008 06:33:09 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.247]) by postgresql.org (Postfix) with ESMTP id BB7CE650E87 for ; Tue, 24 Jun 2008 06:33:12 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id d30so645649and.33 for ; Tue, 24 Jun 2008 02:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=R6hoY4/9Hp3LS5ojo1FFgRBpRL2XN3NBw/7cBWI+ZuE=; b=Tm2jq4mM3yzSJtUdE0wlx9jHANhFHFkJwk2ejnbaRIuew4DqUh/61N8jnevXL/XEdR iNpBMWTB6XnRHtvWtKCHuu3IKCpwD3L9nADVTGxcX0d1AN5JPREIK4gJZK9Xx6dob2QS 8VING8SW26DzbSMPiIrrMUKNWBZvI1r3v0jXs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=dbzP1LjhMArLIMgFSFG2CrW64MLMVezMgC0RSnCu7eQwaoRnQdCY1yAnBqSRUfZO+s 43hhrawdyNC3SKwgh97K4jKQUqnffR1VCX1rRA0Sp9ruUvcivaBVF47KaNindXFg5pIC GEe+RBvZZyr1smgkGDQCGjo9awQK7dpQI5ZzQ= Received: by 10.100.124.6 with SMTP id w6mr15402662anc.44.1214299990982; Tue, 24 Jun 2008 02:33:10 -0700 (PDT) Received: by 10.100.131.7 with HTTP; Tue, 24 Jun 2008 02:33:10 -0700 (PDT) Message-ID: <1d581afe0806240233p27f31f41h9b4b58f6db4a50c7@mail.gmail.com> Date: Tue, 24 Jun 2008 18:33:10 +0900 From: "Ian Barwick" To: "Scott Marlowe" Subject: Re: Postgresql is very slow Cc: bijayant4u@yahoo.com, tv@fuzzy.cz, pgsql-performance@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20229.217.77.161.17.1214229014.squirrel@sq.gransy.com> <569091.76971.qm@web32704.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/114 X-Sequence-Number: 30464 2008/6/24 Scott Marlowe : > On Mon, Jun 23, 2008 at 11:48 PM, bijayant kumar wrote: (...) >> The output of EXPLAIN query; >> >> select * from USERS where email like '%bijayant.kumar%'; >> This simplest query tooks 10 minutes and server loads goes from 0.35 to 16.94. >> >> EXPLAIN select * from USERS where email like '%bijayant.kumar%'; >> QUERY PLAN >> -------------------------------------------------------------- >> Seq Scan on USERS (cost=0.00..54091.84 rows=1 width=161) >> Filter: ((email)::text ~~ '%bijayant.kumar%'::text) >> (2 rows) > > You're scanning ~ 54094 sequential pages to retrieve 1 row. Note > that explain analyze is generally a better choice, it gives more data > useful for troubleshooting. > > Definitely need a vacuum full on this table, likely followed by a reindex. This is a LIKE query with a wildcard at the start of the string to match, reindexing won't help much. Ian Barwick