X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 910BFD1B91B for ; Tue, 6 Apr 2004 01:41:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84992-04 for ; Mon, 5 Apr 2004 22:41:54 -0300 (ADT) Received: from exchange.rampageusa.net (exchange.dslextreme.com [66.51.198.16]) by svr1.postgresql.org (Postfix) with ESMTP id 57B0DD1ED8E for ; Mon, 5 Apr 2004 22:41:19 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C41B78.3BF37693" Subject: Wierd issues Date: Mon, 5 Apr 2004 18:41:08 -0700 Message-ID: <79AEF92046759442A4AA04C2AB08C0B80834E2@exchange.corp.dslextreme.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Wierd issues Thread-Index: AcQbeDuW3/erCMLlTduaiu8lxIPCEQ== From: "Andrew Matthews" To: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/63 X-Sequence-Number: 6363 This is a multi-part message in MIME format. ------_=_NextPart_001_01C41B78.3BF37693 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This is what I got... =20 Two servers, one debian, one fedora =20 Debain dual 3ghz, 1 gig ram, ide, PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4 =20 =20 Fedora: Dual 3ghz, 1 gig ram, scsi, PostgreSQL 7.3.4-RH on i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1) =20 =20 Both have same databases, Both have had vacume full ran on them. Both doing the same query =20 Select * from vpopmail; The vpopmail is a view, this is the view =20 =20 View "vpopmail" Column | Type | Modifiers=20 -----------+------------------------+----------- pw_name | character varying(32) |=20 pw_domain | character varying(64) |=20 pw_passwd | character varying |=20 pw_uid | integer |=20 pw_gid | integer |=20 pw_gecos | character varying |=20 pw_dir | character varying(160) |=20 pw_shell | character varying(20) |=20 View definition: SELECT ea.email_name AS pw_name, ea.domain AS pw_domain, get_pwd(u.username, '127.0.0.1'::"varchar", '101'::"varchar", 'MD5'::"varchar") AS pw_passwd, 0 AS pw_uid, 0 AS pw_gid, ''::"varchar" AS pw_gecos, ei.directory AS pw_dir, ei.quota AS pw_shell FROM email_addresses ea, email_info ei, users u, user_resources ur WHERE (((((ea.user_resource_id =3D ei.user_resource_id) AND (get_pwd(u.username, '127.0.0.1'::"varchar", '101'::"varchar", 'MD5'::"varchar") IS NOT NULL)) AND (ur.id =3D ei.user_resource_id)) AND (u.id =3D ur.user_id)) AND (NOT (EXISTS (SELECT forwarding.email_id FROM forwarding WHERE (forwarding.email_id =3D ea.id))))); =20 =20 =20 Both are set to the same buffers and everything... this is the execution time: =20 Debian: Total runtime: 35594.81 msec =20 Fedora: Total runtime: 2279869.08 msec =20 Huge difference as you can see... here are the pastes of the stuff =20 Debain: =20 user_acl=3D# explain analyze SELECT count(*) from vpopmail; NOTICE: QUERY PLAN: =20 Aggregate (cost=3D438231.94..438231.94 rows=3D1 width=3D20) (actual time=3D35594.67..35594.67 rows=3D1 loops=3D1) -> Hash Join (cost=3D434592.51..438142.51 rows=3D35774 width=3D20) (act= ual time=3D34319.24..35537.11 rows=3D70613 loops=3D1) -> Seq Scan on email_info ei (cost=3D0.00..1721.40 rows=3D71640 width=3D4) (actual time=3D0.04..95.13 rows=3D71689 loops=3D1) -> Hash (cost=3D434328.07..434328.07 rows=3D35776 width=3D16) (actual time=3D34319.00..34319.00 rows=3D0 loops=3D1) -> Hash Join (cost=3D430582.53..434328.07 rows=3D35776 width=3D16) (actual time=3D2372.45..34207.21 rows=3D70613 loops=3D1) -> Seq Scan on users u (cost=3D0.00..1938.51 rows=3D71283 width=3D4) (actual time=3D0.81..30119.58 rows=3D70809 loops=3D= 1) -> Hash (cost=3D430333.64..430333.64 rows=3D35956 width=3D12) (actual time=3D2371.51..2371.51 rows=3D0 loops=3D1) -> Hash Join (cost=3D2425.62..430333.64 rows=3D35956 width=3D12) (actual time=3D176.73..2271.14 rows=3D71470 loops= =3D1) -> Seq Scan on email_addresses ea (cost=3D0.00..426393.25 rows=3D35956 width=3D4) (actual time=3D0.06..627.49 rows=3D71473 loops=3D1) SubPlan -> Index Scan using forwarding_idx on forwarding (cost=3D0.00..5.88 rows=3D1 width=3D4) (actual time=3D0.00..0.00 rows=3D0 loops=3D71960) -> Hash (cost=3D1148.37..1148.37 rows=3D71637 width=3D8) (actual time=3D176.38..176.38 rows=3D0 loops=3D1) -> Seq Scan on user_resources ur (cost=3D0.00..1148.37 rows=3D71637 width=3D8) (actual time=3D0.03..82.21 rows=3D71686 loops=3D1) Total runtime: 35594.81 msec =20 EXPLAIN =20 =20 =20 And for fedora it's =20 =20 Aggregate (cost=3D416775.52..416775.52 rows=3D1 width=3D20) (actual time=3D2279868.57..2279868.58 rows=3D1 loops=3D1) -> Hash Join (cost=3D413853.79..416686.09 rows=3D35772 width=3D20) (actual time=3D2279271.26..2279803.91 rows=3D70841 loops=3D1) Hash Cond: ("outer".user_resource_id =3D "inner".id) -> Seq Scan on email_info ei (cost=3D0.00..1666.07 rows=3D71907 width=3D4) (actual time=3D8.12..171.10 rows=3D71907 loops=3D1) -> Hash (cost=3D413764.36..413764.36 rows=3D35772 width=3D16) (actual time=3D2279263.03..2279263.03 rows=3D0 loops=3D1) -> Hash Join (cost=3D410712.87..413764.36 rows=3D35772 width=3D16) (actual time=3D993.90..2279008.72 rows=3D70841 loops=3D1) Hash Cond: ("outer".id =3D "inner".user_id) -> Seq Scan on users u (cost=3D0.00..1888.85 rows=3D71548 width=3D4) (actual time=3D18.38..2277152.51 rows=3D71028 loops= =3D1) Filter: (get_pwd(username, '127.0.0.1'::character varying, '101'::character varying, 'MD5'::character varying) IS NOT NULL) -> Hash (cost=3D410622.99..410622.99 rows=3D35952 width=3D12) (actual time=3D975.40..975.40 rows=3D0 loops=3D1) -> Hash Join (cost=3D408346.51..410622.99 rows=3D35952 width=3D12) (actual time=3D507.52..905.91 rows=3D71697 loops= =3D1) Hash Cond: ("outer".id =3D "inner".user_resource_id) -> Seq Scan on user_resources ur (cost=3D0.00..1108.04 rows=3D71904 width=3D8) (actual time=3D0.05..95.65 rows=3D71904 loops=3D1) -> Hash (cost=3D408256.29..408256.29 rows=3D36091 width=3D4) (actual time=3D507.33..507.33 rows=3D0 loops=3D1) -> Seq Scan on email_addresses ea (cost=3D0.00..408256.29 rows=3D36091 width=3D4) (actual time=3D0.15..43= 2.83 rows=3D71700 loops=3D1) Filter: (NOT (subplan)) SubPlan -> Index Scan using forwarding_idx on forwarding (cost=3D0.00..5.63 rows=3D1 width=3D4) (actual time=3D0.00..0.00 rows=3D0 loops=3D72182) Index Cond: (email_id =3D $0) Total runtime: 2279869.08 msec (20 rows) =20 =20 =20 Any suggestions? =20 I can't figure this out. There is no reason it should be that much of a difference, It's all the same value's, Thanks in advanced. =20 Andrew ------_=_NextPart_001_01C41B78.3BF37693 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

This is what I got…

 

Two servers, one debian, one fedora

 

Debain dual 3ghz, 1 gig ram, ide, PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4

 

 

Fedora: Dual 3ghz, 1 gig ram, scsi, PostgreSQL 7.3.4-RH = on i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.3.2 20031022 (Red Hat Linux 3.3.2-1)

 

 

Both have same databases, Both have had vacume full ran = on them. Both doing the same query

 

Select * from vpopmail; The vpopmail is a view, this is = the view

 

 

         &n= bsp;      View "vpopmail"

  Column   |     = ;     Type       &nb= sp;  | Modifiers

-----------+------------------------+-----------

 pw_name   | character varying(32)  = |

 pw_domain | character varying(64)  |

 pw_passwd | character varying   &nb= sp;  |

 pw_uid    | integer  &nbs= p;             = |

 pw_gid    | integer  &nbs= p;             = |

 pw_gecos  | character varying  &nbs= p;   |

 pw_dir    | character varying(160) = |

 pw_shell  | character varying(20)  |

View definition: SELECT ea.email_name AS pw_name, ea.dom= ain AS pw_domain, get_pwd(u.username, '127.0.0.1'::"varchar", '101'::"varchar", 'MD5'::"varchar") AS pw_passwd, 0 AS pw_uid, 0 AS pw_gid, ''::"varchar" AS pw_gecos, ei.directory AS pw_dir, ei.quota AS pw_shell FROM email_addresses ea, email_info ei, users = u, user_resources ur WHERE (((((ea.user_resource_id =3D ei.user_resource_id) A= ND (get_pwd(u.username, '127.0.0.1'::"varchar", '101'::"varchar", 'MD5'::"varchar") IS NOT NULL)) AND (ur.id =3D ei.user_resource_id)) AND (u.id =3D ur.user_id)) AND (NOT (EXISTS (SELECT forwarding.email_id FROM forwarding WHERE (forwarding.email_id =3D ea.id)))));

 

 

 

Both are set to the same buffers and everything… t= his is the execution time:

 

Debian: Total runtime: 35594.81 msec

 

Fedora: Total runtime: 2279869.08 msec=

 

Huge difference as you can see… here are the paste= s of the stuff

 

Debain:

 

user_acl=3D# explain analyze SELECT count(*) from vpopma= il;

NOTICE:  QUERY PLAN:

 

Aggregate  (cost=3D438231.94..438231.94 rows=3D1 wi= dth=3D20) (actual time=3D35594.67..35594.67 rows=3D1 loops=3D1)

  ->  Hash Join  (cost=3D434592.51..43= 8142.51 rows=3D35774 width=3D20) (actual time=3D34319.24..35537.11 rows=3D70613 loops=3D1)<= /o:p>

        ->  S= eq Scan on email_info ei  (cost=3D0.00..1721.40 rows=3D71640 width=3D4) (actual time=3D0.04..95.13 ro= ws=3D71689 loops=3D1)

        ->  H= ash  (cost=3D434328.07..434328.07 rows=3D35776 width=3D16) (actual time=3D34319.00..34319.00 rows=3D0 loops=3D1)

         &n= bsp;    ->  Hash Join  (cost=3D430582.53..43432= 8.07 rows=3D35776 width=3D16) (actual time=3D2372.45..34207.21 rows=3D70613 loop= s=3D1)

         &n= bsp;          ->  Seq = Scan on users u  (cost=3D0.00..1938.51 rows=3D71283 width=3D4) (actual time=3D0.81..30119.58= rows=3D70809 loops=3D1)

         &n= bsp;          ->  Hash=   (cost=3D430333.64..430333.64 rows=3D35956 width=3D12) (actual time=3D2371.51..2371.51 rows=3D0 loops=3D1= )

         &n= bsp;            = ;    ->  Hash Join  (cost=3D2425.62..430333.64 rows=3D35956 width=3D12) (actual time=3D176.73..= 2271.14 rows=3D71470 loops=3D1)

         &n= bsp;            = ;          ->  Seq Sca= n on email_addresses ea  (cost=3D0.00..426393.25 rows=3D35956 width=3D4) (a= ctual time=3D0.06..627.49 rows=3D71473 loops=3D1)

         &n= bsp;            = ;            &n= bsp;   SubPlan

         &n= bsp;            = ;            &n= bsp;     ->  Index Scan using forwarding_idx on forwarding  (cost=3D0.00..5.88 rows=3D1 width= =3D4) (actual time=3D0.00..0.00 rows=3D0 loops=3D71960)

          &= nbsp;           &nbs= p;         ->  Hash&nb= sp; (cost=3D1148.37..1148.37 rows=3D71637 width=3D8) (actual time=3D176.38..176= .38 rows=3D0 loops=3D1)

         &n= bsp;            = ;            &n= bsp;   ->  Seq Scan on user_resources ur<= /st1:City>  (cost=3D0.00..1148.37 rows=3D71637 width=3D8) (actual time=3D0.03..82.21 ro= ws=3D71686 loops=3D1)

Total runtime: 35594.81 msec

 

EXPLAIN

 

 

 

And for fedora it’s

 

 

Aggregate  (cost=3D416775.52..416775.52 row=
s=3D1 width=3D20) (actual time=3D2279868.57..2279868.58 rows=3D1 loops=3D1)=
   ->&nb=
sp; Hash Join  (cost=3D413853.79..416686.09 rows=3D35772 width=3D20) (=
actual time=3D2279271.26..2279803.91 rows=3D70841 loops=3D1)
   &nb=
sp;     Hash Cond: ("outer".user_resource_id =
=3D "inner".id)
   &nb=
sp;     ->  Seq Scan on email_info ei  (co=
st=3D0.00..1666.07 rows=3D71907 width=3D4) (actual time=3D8.12..171.10 rows=
=3D71907 loops=3D1)
   &nb=
sp;     ->  Hash  (cost=3D413764.36..41376=
4.36 rows=3D35772 width=3D16) (actual time=3D2279263.03..2279263.03 rows=3D=
0 loops=3D1)
   &nb=
sp;           -> =
 Hash Join  (cost=3D410712.87..413764.36 rows=3D35772 width=3D16) (act=
ual time=3D993.90..2279008.72 rows=3D70841 loops=3D1)
   &nb=
sp;            =
     Hash Cond: ("outer".id =3D "inner&q=
uot;.user_id)
   &nb=
sp;            =
     ->  Seq Scan on users u  (cost=3D0.00=
..1888.85 rows=3D71548 width=3D4) (actual time=3D18.38..2277152.51 rows=3D7=
1028 loops=3D1)
   &nb=
sp;            =
           Filter: (get_p=
wd(username, '127.0.0.1'::character varying, '101'::character varying, 'MD5=
'::character varying) IS NOT NULL)
   &nb=
sp;            =
     ->  Hash  (cost=3D410622.99..410622.9=
9 rows=3D35952 width=3D12) (actual time=3D975.40..975.40 rows=3D0 loops=3D1=
)
   &nb=
sp;             =
;          ->  Ha=
sh Join  (cost=3D408346.51..410622.99 rows=3D35952 width=3D12) (actual=
 time=3D507.52..905.91 rows=3D71697 loops=3D1)
   &nb=
sp;            =
            &nb=
sp;    Hash Cond: ("outer".id =3D "inner"=
;.user_resource_id)
   &nb=
sp;            =
            &nb=
sp;    ->  Seq Scan on user_resources ur  (cost=3D=
0.00..1108.04 rows=3D71904 width=3D8) (actual time=3D0.05..95.65 rows=3D719=
04 loops=3D1)
   &nb=
sp;            =
            &nb=
sp;    ->  Hash  (cost=3D408256.29..408256.29 r=
ows=3D36091 width=3D4) (actual time=3D507.33..507.33 rows=3D0 loops=3D1)
   &nb=
sp;             =
;            &n=
bsp;         ->  Seq S=
can on email_addresses ea  (cost=3D0.00..408256.29 rows=3D36091 width=
=3D4) (actual time=3D0.15..432.83 rows=3D71700 loops=3D1)=
   &nb=
sp;            =
            &nb=
sp;            =
    Filter: (NOT (subplan))
   &nb= sp;            =             &nb= sp;             = ;   SubPlan
   &nb=
sp;            =
            &nb=
sp;            =
      ->  Index Scan using forwarding_idx =
on forwarding  (cost=3D0.00..5.63 rows=3D1 width=3D4) (actual time=3D0=
.00..0.00 rows=3D0 loops=3D72182)
   &nb=
sp;            =
            &nb=
sp;            =
            Index Co=
nd: (email_id =3D $0)
 Total runtime: 22798=
69.08 msec

(20 rows)

 

 

 

Any suggestions?

 

I can’t figure this out. There is no reason it should be that much of a difference, It’s all the same value’s, Thanks in advanced.

 

Andrew

------_=_NextPart_001_01C41B78.3BF37693--