X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 9FA8C9FA1B0 for ; Wed, 10 May 2006 12:14:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 10539-08 for ; Wed, 10 May 2006 12:14:30 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from fw.greenpeace.org (fw.greenpeace.org [212.19.215.77]) by postgresql.org (Postfix) with ESMTP id 9AD739FA8EF for ; Wed, 10 May 2006 12:14:29 -0300 (ADT) Received: (from root@localhost) by fw.greenpeace.org (8.9.3c/8.6.12) id RAA57295 for ; Wed, 10 May 2006 17:14:28 +0200 (CEST) Received: by fw.greenpeace.org (TUNIX/Firewall SMTP Server) for id sma036091; Wed, 10 May 06 17:01:56 +0200 Received: from bb.nli.gl3 (root@localhost) by bb.nli.gl3 (8.12.8/8.12.5) with SMTP id k4AF1uh5026056 for ; Wed, 10 May 2006 17:01:56 +0200 Received: from maila.greenpeace.org (fw.nli.gl3 [192.168.31.7]) by bb.nli.gl3 (8.12.8/8.13.3) with ESMTP id k4AF1u7j026047; Wed, 10 May 2006 17:01:56 +0200 Received: from [192.168.200.143] (vpni.greenpeace.org [212.19.215.76]) (authenticated (128 bits)) by maila.greenpeace.org (8.13.4/8.11.6) with ESMTP id k4AF1tBO026589 (using TLSv1/SSLv3 with cipher RC4-MD5 (128 bits) verified NO); Wed, 10 May 2006 17:01:56 +0200 Message-ID: <44620083.10503@superlativ.dk> Date: Wed, 10 May 2006 17:02:27 +0200 From: Nis Jorgensen User-Agent: Opera/7.5 (Windows; U; Longhorn; en-US; rv:1.0.0) MIME-Version: 1.0 To: Clemens Eisserer CC: pgsql-performance@postgresql.org Subject: Re: Question about explain-command... References: <194f62550605100449p2d200fc3pfe501da895cfcc00@mail.gmail.com> In-Reply-To: <194f62550605100449p2d200fc3pfe501da895cfcc00@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Anti-Virus: Kaspersky Anti-Virus for MailServers 5.5.2/RELEASE, bases: 25072005 #131892, status: clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/259 X-Sequence-Number: 19046 I will try answering your questions. Please note that I am a newbie myself. Clemens Eisserer wrote > All primary keys are indixed, and this is what explain tells me: > Unique (cost=15.67..16.69 rows=34 width=115) > -> Sort (cost=15.67..15.75 rows=34 width=115) > Sort Key: customer.email, customer."key", customer.anrede, customer.str > asse, customer.plz, customer.ort, customer.vorname, customer.nachname, custtype. > name, customer.land, customer.datanotvalid > -> Hash Left Join (cost=6.16..14.80 rows=34 width=115) > Hash Cond: ("outer".prodgroup = "inner"."key") > -> Hash Left Join (cost=4.97..13.10 rows=34 width=119) > Hash Cond: ("outer".custgroup = "inner"."key") > -> Hash Left Join (cost=3.88..11.49 rows=34 width=111) > Hash Cond: ("outer".goodsid = "inner"."key") > -> Hash Left Join (cost=1.98..9.08 > rows=34 width=11 1) > Hash Cond: ("outer"."key" = "inner".custid) > -> Seq Scan on customer (cost=0.00..6.10 rows =34 width=107) > Filter: ((nachname)::text ~~ > '%au%'::text ) > -> Hash (cost=1.78..1.78 rows=78 width=8) > -> Seq Scan on sells (cost=0.00..1.78 r ows=78 width=8) > -> Hash (cost=1.72..1.72 rows=72 width=8) > -> Seq Scan on goods (cost=0.00..1.72 rows=72 width=8) > -> Hash (cost=1.08..1.08 rows=8 width=16) > -> Seq Scan on custtype (cost=0.00..1.08 > rows=8 wid th=16) > -> Hash (cost=1.15..1.15 rows=15 width=4) > -> Seq Scan on prodtype (cost=0.00..1.15 rows=15 width=4) > What does the hash-lines mean, does that mean my query does not use > the indices at all? Yes. Probably each table fits nicely into a single disk read, so reading both the index AND the table is going to be twice as expensive. > Why are some table-names and some column-names surrounded by ' " '? > Are they threated as text-columns? They are either names generated by postgres ("outer" and "inner") or field names which are also reserved words in SQL ("key"). You can always use double quotes around a field name - you have to in some cases if they are reserved words, and always if they contain "special characters" (not sure from memory exactly which these are - at least spaces). I recommend not to use either of these, even if a reserved word is the best description of your field. Postgres seems to be a bit better than some other dbms's in allowing unquoted reserved words as field names if there is no ambiguity. Thsis may mean that you get a problem if your application is ever ported to a different dbms. > I have to admit that the tables are just filled with test-data so the > analyzer may take just a very simple way since almost no data is in... Try loading your tables with a realistic number of customers, and you should see a change in the query plan to use your precious indexes. /Nis