Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id C81772E2DAA for ; Thu, 15 Nov 2007 11:14:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 82346-01 for ; Thu, 15 Nov 2007 11:14:43 -0400 (AST) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.189]) by postgresql.org (Postfix) with ESMTP id D2C882E2DA5 for ; Thu, 15 Nov 2007 11:14:43 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id f5so440547nfh for ; Thu, 15 Nov 2007 07:14:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=ouv6zPS0ziFL9/BMhm9Kd1VMdc2KQNkbnmsmBTCPKYs=; b=K752lGwKSZYAQ2NPNuhTuLVXDTkQCLn225dv+BTZT4mkdY3by8R+8Fmzv31vBGvA0WfmX0Vh74/F8wHDf/zzZS6WymcrsTeFXE3PUFDjoMu37BrQWFw+EfpO+o4sg8r6mKiIaGEri3kor9RbfeR4eYS1as+LL4BpTQefEgukUOM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=sTxX6m9bsMpQ5dQuIlaRxWth6Uwe8J8UVBRIMqvpP7yVkrdGFnomwHBTjb5Th/HECYNMdgFZ9G+6U6V9ot5f7jDILPGBSONk8GA33N1AIN0G0w0LBrr7/igRpPAxf2pQ0ULqPT+vQH19g8ffiU2EVjJJrVbD1o7SbpXRxVZjGUs= Received: by 10.78.170.17 with SMTP id s17mr699181hue.1195139681634; Thu, 15 Nov 2007 07:14:41 -0800 (PST) Received: by 10.78.197.6 with HTTP; Thu, 15 Nov 2007 07:14:41 -0800 (PST) Message-ID: <1d219a6f0711150714j6f192548xe4c134a25e5b57b2@mail.gmail.com> Date: Thu, 15 Nov 2007 10:14:41 -0500 From: "Chris Hoover" To: "pgsql-admin@postgresql.org Admin" Subject: any way to make query use index? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/140 X-Sequence-Number: 27383 I am working through our application looking for ways to eliminate seq scans in our database. I am looking for some help with this query. SELECT rev_desc FROM rev_code_desc WHERE rev_code = lpad('0300', 4, '0') Is there anyway to make postgres use an index on this query? Here is the table definition: CREATE TABLE rev_code_desc ( rev_code character(4) NOT NULL, rev_desc text, user_id character varying(12), live_rec boolean DEFAULT true, CONSTRAINT rev_code_desc_pkey PRIMARY KEY (rev_code) ) Right now, I can't seem to get it to use an index for this type of query. Of course, in our application it is SELECT rev_desc FROM rev_code_desc WHERE rev_code = lpad(, 4, '0'). Thanks for any help, Chris PG 8.1.3