Jdbc/postgres performance

From: "Rohit_Behl" <Rohit_Behl(at)infosys(dot)com>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Jdbc/postgres performance
Date: 2006-10-17 19:45:40
Message-ID: 407937EC76157D439EB0C9F9B6047EFD40017C@BLRKECMSG04.ad.infosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


Hi

We are facing performance problems in postgres while executing a query. When I execute this query on the server it takes 5-10 seconds. Also I get good performance while executing this query from my code in java with the hard codes values. I face severe performance problems when I run it using a prepared statement.

The query is as follows:

Select events.event_id, ctrl.real_name, events.tsds, events.value, events.lds, events.correction, ctrl.type, ctrl.freq from iso_midw_data_update_events events, iso_midw_control ctrl where events.obj_id = ctrl.obj_id and events.event_id > 68971124 order by events.event_id limit 2000

The above query executes in 5-10 seconds.

However the below query executes in 8 mins:

Select events.event_id, ctrl.real_name, events.tsds, events.value, events.lds, events.correction, ctrl.type, ctrl.freq from table events, iso_midw_control ctrl where events.obj_id = ctrl.obj_id and events.event_id > ?::bigint order by events.event_id limit ?

setLong(1, 68971124);

setInt(2, 2000);

The table has close to 5 million rows. The table has the following index:

iso_midw_data_update_events_event_id_key

iso_midw_data_update_events_lds_idx

iso_midw_data_update_events_obj_id_idx

The table is described as follows:

Columns_name data_type type_name column_size

lds 2 numeric 13

obj_id 2 numeric 6

tsds 2 numeric 13

value 12 varchar 22

correction 2 numeric 1

delta_lds_tsds 2 numeric 13

event_id -5 bigserial 8

Please tell me what I am missing while setting the prepared statement. I am using postgres7.4.2. and postgresql-8.1-407.jdbc3.jar.

Thanks

Regards

Rohit

**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2006-10-17 20:28:49 Re: Jdbc/postgres performance
Previous Message Shane Ambler 2006-10-17 19:41:03 Re: Optimization of this SQL sentence