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 98C9B564DA for ; Tue, 22 Mar 2005 09:49:29 +0000 (GMT) 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 41606-01 for ; Tue, 22 Mar 2005 09:49:25 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) by svr1.postgresql.org (Postfix) with ESMTP id A557A56439 for ; Tue, 22 Mar 2005 09:49:23 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id y7so1229212rne for ; Tue, 22 Mar 2005 01:49:26 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=Kxiz56uBhdsQYgGHnmwEiRulDeYh0HO9X7D7g4e4Eh9/nkqLqle+i5ZnfiK9vx2WzY262tfxAiEqZ96OBlIj3wSaNUTSlORiOaPhpIrZzhPYgIVF5MalOHUC0b/qkL0wCbRkWuywpXcROWBboiJ9cjpLOvK/h+8TKca7f8SjMEU= Received: by 10.38.65.20 with SMTP id n20mr6158813rna; Tue, 22 Mar 2005 01:49:25 -0800 (PST) Received: by 10.38.101.75 with HTTP; Tue, 22 Mar 2005 01:49:25 -0800 (PST) Message-ID: <758d5e7f050322014953c311fe@mail.gmail.com> Date: Tue, 22 Mar 2005 10:49:25 +0100 From: Dawid Kuroczko Reply-To: Dawid Kuroczko To: pgsql-performance@postgresql.org Subject: Re: best practices with index on varchar column In-Reply-To: <007301c52ec0$a8f64ec0$9285a8c0@moonfactory.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit References: <007301c52ec0$a8f64ec0$9285a8c0@moonfactory.co.jp> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.738 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FROM_ENDS_IN_NUMS, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200503/430 X-Sequence-Number: 11135 On Tue, 22 Mar 2005 18:22:24 +0900, Layet Benjamin wrote: > Can I use an index on a varchar column to optimize the SELECT queries that > use " column LIKE 'header%' "? > If yes what is the best tree algotithm to use ? Yes, that is the correct place. The best tree algorithm is B-Tree, which is the default. So no need for giving 'USING ...' to CREATE INDEX. The other types of indexes are either not trees (HASH), different and more complex (GiST, RTREE) kinds of trees which are there for different kinds of data (spatial, full text, etc). Remember to VACUUM ANALYZE this table from time to time, so the planner can judge efficiently whether to use this new index or not. Use EXPLAIN ANALYZE SELECT .... to see whether the index is really used. > I don't care about optimising INSERT, DELETE and UPDATE queries, as they are > only done at night when the load is very low. > Thank you very much for any help, Oh, they can benefit from the index anyhow. :) Regards, Dawid