Any way to speed this up?

Поиск
Список
Период
Сортировка
От Joel Fradkin
Тема Any way to speed this up?
Дата
Msg-id 005301c53b84$6b83f8a0$797ba8c0@jfradkin
обсуждение исходный текст
Ответы Re: Any way to speed this up?  ("Keith Worthington" <keithw@narrowpathinc.com>)
Re: Any way to speed this up?  (John Arbash Meinel <john@arbash-meinel.com>)
Re: Any way to speed this up?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance

Running this explain on windows box, but production on linux both 8.0.1

The MSSQL is beating me out for some reason on this query.

The linux box is much more powerful, I may have to increase the cache, but I am pretty sure its not an issue yet.

It has 8 gig internal memory any recommendation on the cache size to use?

 

explain analyze select * from viwassoclist where clientnum = 'SAKS'

 

"Merge Join  (cost=59871.79..60855.42 rows=7934 width=112) (actual time=46906.000..48217.000 rows=159959 loops=1)"

"  Merge Cond: ("outer".locationid = "inner".locationid)"

"  ->  Sort  (cost=393.76..394.61 rows=338 width=48) (actual time=62.000..62.000 rows=441 loops=1)"

"        Sort Key: l.locationid"

"        ->  Index Scan using ix_location on tbllocation l  (cost=0.00..379.56 rows=338 width=48) (actual time=15.000..62.000 rows=441 loops=1)"

"              Index Cond: ('SAKS'::text = (clientnum)::text)"

"  ->  Sort  (cost=59478.03..59909.58 rows=172618 width=75) (actual time=46844.000..46985.000 rows=159960 loops=1)"

"        Sort Key: a.locationid"

"        ->  Merge Right Join  (cost=0.00..39739.84 rows=172618 width=75) (actual time=250.000..43657.000 rows=176431 loops=1)"

"              Merge Cond: ((("outer".clientnum)::text = ("inner".clientnum)::text) AND ("outer".id = "inner".jobtitleid))"

"              ->  Index Scan using ix_tbljobtitle_id on tbljobtitle jt  (cost=0.00..194.63 rows=6391 width=37) (actual time=32.000..313.000 rows=5689 loops=1)"

"                    Filter: (1 = presentationid)"

"              ->  Index Scan using ix_tblassoc_jobtitleid on tblassociate a  (cost=0.00..38218.08 rows=172618 width=53) (actual time=31.000..41876.000 rows=176431 loops=1)"

"                    Index Cond: ((clientnum)::text = 'SAKS'::text)"

"Total runtime: 48500.000 ms"

 

CREATE OR REPLACE VIEW viwassoclist AS

 SELECT a.clientnum, a.associateid, a.associatenum, a.lastname, a.firstname, jt.value AS jobtitle, l.name AS "location", l.locationid AS mainlocationid, l.divisionid, l.regionid, l.districtid, (a.lastname::text || ', '::text) || a.firstname::text AS assocname, a.isactive, a.isdeleted

   FROM tblassociate a

   LEFT JOIN tbljobtitle jt ON a.jobtitleid = jt.id AND jt.clientnum::text = a.clientnum::text AND 1 = jt.presentationid

   JOIN tbllocation l ON a.locationid = l.locationid AND l.clientnum::text = a.clientnum::text;

 

 

CREATE TABLE tblassociate

(

  clientnum varchar(16) NOT NULL,

  associateid int4 NOT NULL,

  associatenum varchar(10),

  firstname varchar(50),

  middleinit varchar(5),

  lastname varchar(50),

  ssn varchar(18),

  dob timestamp,

  address varchar(100),

  city varchar(50),

  state varchar(50),

  country varchar(50),

  zip varchar(10),

  homephone varchar(14),

  cellphone varchar(14),

  pager varchar(14),

  associateaccount varchar(50),

  doh timestamp,

  dot timestamp,

  rehiredate timestamp,

  lastdayworked timestamp,

  staffexecid int4,

  jobtitleid int4,

  locationid int4,

  deptid int4,

  positionnum int4,

  worktypeid int4,

  sexid int4,

  maritalstatusid int4,

  ethnicityid int4,

  weight float8,

  heightfeet int4,

  heightinches int4,

  haircolorid int4,

  eyecolorid int4,

  isonalarmlist bool NOT NULL DEFAULT false,

  isactive bool NOT NULL DEFAULT true,

  ismanager bool NOT NULL DEFAULT false,

  issecurity bool NOT NULL DEFAULT false,

  createdbyid int4,

  isdeleted bool NOT NULL DEFAULT false,

  militarybranchid int4,

  militarystatusid int4,

  patrontypeid int4,

  identificationtypeid int4,

  workaddress varchar(200),

  testtypeid int4,

  testscore int4,

  pin int4,

  county varchar(50),

  CONSTRAINT pk_tblassociate PRIMARY KEY (clientnum, associateid),

  CONSTRAINT ix_tblassociate UNIQUE (clientnum, associatenum)

)

 

CREATE TABLE tbljobtitle

(

  clientnum varchar(16) NOT NULL,

  id int4 NOT NULL,

  value varchar(50),

  code varchar(16),

  isdeleted bool DEFAULT false,

  presentationid int4 NOT NULL DEFAULT 1,

  CONSTRAINT pk_tbljobtitle PRIMARY KEY (clientnum, id, presentationid)

)

 

CREATE TABLE tbllocation

(

  clientnum varchar(16) NOT NULL,

  locationid int4 NOT NULL,

  districtid int4 NOT NULL,

  regionid int4 NOT NULL,

  divisionid int4 NOT NULL,

  locationnum varchar(8),

  name varchar(50),

  clientlocnum varchar(50),

  address varchar(100),

  address2 varchar(100),

  city varchar(50),

  state varchar(2) NOT NULL DEFAULT 'zz'::character varying,

  zip varchar(10),

  countryid int4,

  phone varchar(15),

  fax varchar(15),

  payname varchar(40),

  contact char(36),

  active bool NOT NULL DEFAULT true,

  coiprogram text,

  coilimit text,

  coiuser varchar(255),

  coidatetime varchar(32),

  ec_note_field varchar(1050),

  locationtypeid int4,

  open_time timestamp,

  close_time timestamp,

  insurance_loc_id varchar(50),

  lpregionid int4,

  sic int4,

  CONSTRAINT pk_tbllocation PRIMARY KEY (clientnum, locationid),

  CONSTRAINT ix_tbllocation_1 UNIQUE (clientnum, locationnum, name),

  CONSTRAINT ix_tbllocation_unique_number UNIQUE (clientnum, divisionid, regionid, districtid, locationnum)

)

 

Joel Fradkin

 

 

В списке pgsql-performance по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Recognizing range constraints (was Re: Plan for relatively simple query seems to be very inefficient)
Следующее
От: "Mohan, Ross"
Дата:
Сообщение: Building postmaster with Profiling Support WAS "Tweaking a C Function I wrote"