Re: [GENERAL] Prepared Statements and Pooling

2015-08-11 Thread Andomar
I have considered opening a single connection to the server and letting all threads execute statements through it, and use prepared statements (serviced by postgresql, not JDBC or DBCP). Or simply opening 50 connections and establishing prepared statements and then handing them off to the

Re: [GENERAL] Prepared Statements and Pooling

2015-08-11 Thread Alban Hertroys
On 11 August 2015 at 06:44, Mister Junk junkmail3568...@gmail.com wrote: I'm using prepared statements to prevent SQL injection, but I have done some reading and it seems like using Prepared statements COULD improve performance. I understand the concept, but I do not know how to implement

[GENERAL] Prepared Statements and Pooling

2015-08-10 Thread Mister Junk
I'm working on a project for school that requires a simple java server (a ServerSocket creates Socket connections which I send JSON strings over) which then communicates with a database. Obviously I have chosen PostgreSQL. I'm using Apache DBCP for connection pooling. The DataSource is handed

Re: [GENERAL] Prepared statements with bind parameters for DDL

2015-02-11 Thread Adrian Klaver
On 02/11/2015 09:42 AM, deepak wrote: Hi, I find that one can't have a prepared statement with bind parameters for a DDL statement, although I couldn't find the rationale for this restriction. Is this limitation due to the database design, or is it something that's imposed by the SQL standard

Re: [GENERAL] Prepared statements with bind parameters for DDL

2015-02-11 Thread Tom Lane
deepak deepak...@gmail.com writes: I find that one can't have a prepared statement with bind parameters for a DDL statement, Nope. DDL commands generally don't have any support for evaluating expressions, which would be the context in which parameters would be useful. Nor have they got plans,

[GENERAL] Prepared statements with bind parameters for DDL

2015-02-11 Thread deepak
Hi, I find that one can't have a prepared statement with bind parameters for a DDL statement, although I couldn't find the rationale for this restriction. Is this limitation due to the database design, or is it something that's imposed by the SQL standard and/or the JDBC drivers? Please

Re: [GENERAL] Prepared statements with bind parameters for DDL

2015-02-11 Thread Martijn van Oosterhout
On Wed, Feb 11, 2015 at 02:22:10PM -0500, Tom Lane wrote: deepak deepak...@gmail.com writes: I find that one can't have a prepared statement with bind parameters for a DDL statement, Nope. DDL commands generally don't have any support for evaluating expressions, which would be the

Re: [GENERAL] Prepared statements with bind parameters for DDL

2015-02-11 Thread Tom Lane
Martijn van Oosterhout klep...@svana.org writes: On Wed, Feb 11, 2015 at 02:22:10PM -0500, Tom Lane wrote: Nope. DDL commands generally don't have any support for evaluating expressions, which would be the context in which parameters would be useful. Nor have they got plans, which would be

Re: [GENERAL] Prepared statements and cursors

2014-01-28 Thread Andreas Lubensky
That is an interesting approach. However, I see the problem that the functions would have to be removed when no longer needed. If that fails (broken connection etc.), they would be orphaned. Prepared statements are bound to the connection, so when the connection is closed they are gone. On Thu,

Re: [GENERAL] Prepared statements and cursors

2014-01-28 Thread Merlin Moncure
On Tue, Jan 28, 2014 at 7:53 AM, Andreas Lubensky luben...@cognitec.com wrote: That is an interesting approach. However, I see the problem that the functions would have to be removed when no longer needed. If that fails (broken connection etc.), they would be orphaned. Prepared statements are

[GENERAL] Prepared statements and cursors

2014-01-23 Thread Andreas Lubensky
Hello, When implementing a database backend with libpq I realized that it seems to be impossible to declare a cursor on a prepared statement. Is this correct? What is the reason for this limitation? -- with best regards, Andreas Lubensky -- Sent via pgsql-general mailing list

Re: [GENERAL] Prepared statements and cursors

2014-01-23 Thread Susan Cassidy
pgpool-II may do what you want. On Thu, Jan 23, 2014 at 6:31 AM, Andreas Lubensky luben...@cognitec.comwrote: Hello, When implementing a database backend with libpq I realized that it seems to be impossible to declare a cursor on a prepared statement. Is this correct? What is the reason for

Re: [GENERAL] Prepared statements and cursors

2014-01-23 Thread Susan Cassidy
Sorry, answered wrong posting. On Thu, Jan 23, 2014 at 6:31 AM, Andreas Lubensky luben...@cognitec.comwrote: Hello, When implementing a database backend with libpq I realized that it seems to be impossible to declare a cursor on a prepared statement. Is this correct? What is the reason for

Re: [GENERAL] Prepared statements and cursors

2014-01-23 Thread Merlin Moncure
On Thu, Jan 23, 2014 at 8:31 AM, Andreas Lubensky luben...@cognitec.com wrote: Hello, When implementing a database backend with libpq I realized that it seems to be impossible to declare a cursor on a prepared statement. Is this correct? What is the reason for this limitation? I can't think

[GENERAL] Prepared statements performance

2012-05-10 Thread Daniel McGreal
Hi! My reading to date suggests that prepared statements should be faster to execute than issuing the same statement multiple times. However, issuing 100'000 INSERTs turned out to be more than ten times faster than executing the same prepared statement 100'000 times when executed via pgAdmin. The

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Daniel McGreal
Hi again, I did a follow up test using 'multi-value' inserts which is three times faster than multiple inserts thusly: TRUNCATE test; BEGIN; INSERT INTO test (one, two, three, four, five) VALUES ('2011-01-01', true, 'three', 4, 5.5) ,('2011-01-01', true, 'three', 4, 5.5) -- 99'998 more ,

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Pavel Stehule
Hello 2012/5/10 Daniel McGreal daniel.mcgr...@redbite.com: Hi again, I did a follow up test using 'multi-value' inserts which is three times faster than multiple inserts thusly: if you need speed, use a COPY statement - it should be 10x faster than INSERTS Pavel TRUNCATE test; BEGIN;

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Daniel McGreal
Hi, Unfortunately these are experimental conditions. The conditions surrounding the intended application are such that my two options are prepared statements or many inserts. I put the multi-value inserts in as I was curious as to why prepared statements would be slower given they only plan the

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Alban Hertroys
On 10 May 2012 11:30, Daniel McGreal daniel.mcgr...@redbite.com wrote: I put the multi-value inserts in as I was curious as to why prepared statements would be slower given they only plan the query once (as also does the multi-value insert, I assume). That's a common misconception. The reason

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Radosław Smogura
On Thu, 10 May 2012 13:52:29 +0200, Alban Hertroys wrote: On 10 May 2012 11:30, Daniel McGreal daniel.mcgr...@redbite.com wrote: I put the multi-value inserts in as I was curious as to why prepared statements would be slower given they only plan the query once (as also does the multi-value

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Merlin Moncure
On Thu, May 10, 2012 at 6:52 AM, Alban Hertroys haram...@gmail.com wrote: On 10 May 2012 11:30, Daniel McGreal daniel.mcgr...@redbite.com wrote: I put the multi-value inserts in as I was curious as to why prepared statements would be slower given they only plan the query once (as also does the

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Alban Hertroys
On 10 May 2012 15:05, Radosław Smogura rsmog...@softperience.eu wrote: May I ask what kind of planning may occur during insert? Well, for example, if there's a unique constraint on the table then the database will have to check that the newly inserted values don't conflict with values that are

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Tom Lane
Alban Hertroys haram...@gmail.com writes: On 10 May 2012 15:05, Radosław Smogura rsmog...@softperience.eu wrote: May I ask what kind of planning may occur during insert? Well, for example, if there's a unique constraint on the table then the database will have to check that the newly

Re: [GENERAL] Prepared statements performance

2012-05-10 Thread Daniel McGreal
Doing the same tests from psql gives: 1. ~2.5 seconds for INSERT/VALUES 2. ~10 seconds for prepared statement executes 3. ~15 seconds for multiple INSERTs Dan. On Thu, May 10, 2012 at 3:42 PM, Tom Lane t...@sss.pgh.pa.us wrote: Alban Hertroys haram...@gmail.com writes: On 10 May

Re: [GENERAL] Prepared statements and unknown types

2010-09-30 Thread Igor Neyman
-Original Message- From: Thom Brown [mailto:t...@linux.com] Sent: Wednesday, September 29, 2010 2:08 PM To: PGSQL Mailing List Subject: Prepared statements and unknown types Could someone explain why the following doesn't work? test=# PREPARE meow(unknown) AS test-# SELECT

Re: [GENERAL] Prepared statements and unknown types

2010-09-30 Thread Thom Brown
On 30 September 2010 14:36, Igor Neyman iney...@perceptron.com wrote: -Original Message- From: Thom Brown [mailto:t...@linux.com] Sent: Wednesday, September 29, 2010 2:08 PM To: PGSQL Mailing List Subject: Prepared statements and unknown types Could someone explain why the following

[GENERAL] Prepared statements and unknown types

2010-09-29 Thread Thom Brown
Could someone explain why the following doesn't work? test=# PREPARE meow(unknown) AS test-# SELECT $1 as meow; ERROR: could not determine data type of parameter $1 The problem is that using PDO in PHP, prepared statements aren't possible if values are used instead of columns in the select

Re: [GENERAL] Prepared statements and unknown types

2010-09-29 Thread Peter Bex
On Wed, Sep 29, 2010 at 07:08:22PM +0100, Thom Brown wrote: Could someone explain why the following doesn't work? test=# PREPARE meow(unknown) AS test-# SELECT $1 as meow; ERROR: could not determine data type of parameter $1 The problem is that using PDO in PHP, prepared statements

Re: [GENERAL] Prepared statements and unknown types

2010-09-29 Thread Thom Brown
On 29 September 2010 19:15, Peter Bex peter@xs4all.nl wrote: On Wed, Sep 29, 2010 at 07:08:22PM +0100, Thom Brown wrote: Could someone explain why the following doesn't work? test=# PREPARE meow(unknown) AS test-# SELECT $1 as meow; ERROR:  could not determine data type of parameter $1

Re: [GENERAL] Prepared statements and unknown types

2010-09-29 Thread Peter Bex
On Wed, Sep 29, 2010 at 07:33:53PM +0100, Thom Brown wrote: Okay, I understand what's happening. But does the planner need to understand the type of literals in the select list if it's not used anywhere else? Fields sent back to the client also carry their type with them. There's no unknown

Re: [GENERAL] Prepared statements and unknown types

2010-09-29 Thread Thom Brown
On 29 September 2010 19:41, Peter Bex peter@xs4all.nl wrote: On Wed, Sep 29, 2010 at 07:33:53PM +0100, Thom Brown wrote: Okay, I understand what's happening.  But does the planner need to understand the type of literals in the select list if it's not used anywhere else? Fields sent back

Re: [GENERAL] Prepared statements and unknown types

2010-09-29 Thread Tom Lane
Peter Bex peter@xs4all.nl writes: On Wed, Sep 29, 2010 at 07:33:53PM +0100, Thom Brown wrote: Okay, I understand what's happening. But does the planner need to understand the type of literals in the select list if it's not used anywhere else? Fields sent back to the client also carry

Re: [GENERAL] Prepared statements and unknown types

2010-09-29 Thread Thom Brown
On 29 September 2010 20:02, Tom Lane t...@sss.pgh.pa.us wrote: Peter Bex peter@xs4all.nl writes: On Wed, Sep 29, 2010 at 07:33:53PM +0100, Thom Brown wrote: Okay, I understand what's happening.  But does the planner need to understand the type of literals in the select list if it's not

Re: [GENERAL] prepared statements

2010-07-24 Thread Alban Hertroys
On 24 Jul 2010, at 1:32, Scott Frankel wrote: Works! The bug in my example was not passing the INSERT statement an explicit list of column names, as per any non-prepared insert. You would have needed it for an unprepared statement just as well in this case. You expect the planner to guess

[GENERAL] prepared statements

2010-07-23 Thread Scott Frankel
Hi all, I'm working with prepared statements directly in pg for the first time and have a couple of questions. Does a prepared statement used to insert into a table need to insert into all columns of the table? I've found that, for a table with a serial sequence key as its first column,

Re: [GENERAL] prepared statements

2010-07-23 Thread Daniel Verite
Scott Frankel wrote: I've found that, for a table with a serial sequence key as its first column, I have to specify the key in my prepared statement or I get type errors: ERROR: column foo_id is of type integer but expression is of type character varying. Let's try: test=

Re: [GENERAL] prepared statements

2010-07-23 Thread Scott Frankel
Works! The bug in my example was not passing the INSERT statement an explicit list of column names, as per any non-prepared insert. Thanks! Scott On Jul 23, 2010, at 2:53 PM, Daniel Verite wrote: Scott Frankel wrote: I've found that, for a table with a serial sequence key as

[GENERAL] Prepared statements with a variable number of parameters

2009-10-10 Thread Raymond O'Donnell
I'm using PDO in PHP for database access (actually Zend Framework), and following best practice by using parameters in prepared statements. My question is, what do people normally do when there's a variable number of parameters? - for example: select . where item_id in ( ... ); In this

Re: [GENERAL] Prepared statements with a variable number of parameters

2009-10-10 Thread Pavel Stehule
Hello 2009/10/10 Raymond O'Donnell r...@iol.ie: I'm using PDO in PHP for database access (actually Zend Framework), and following best practice by using parameters in prepared statements. My question is, what do people normally do when there's a variable number of parameters? - for example:

Re: [GENERAL] Prepared statements with a variable number of parameters

2009-10-10 Thread Raymond O'Donnell
On 10/10/2009 18:52, Pavel Stehule wrote: 2009/10/10 Raymond O'Donnell r...@iol.ie: My question is, what do people normally do when there's a variable number of parameters? - for example: select . where item_id in ( ... ); You can use arrays here. select ... where item_id =

Re: [GENERAL] prepared statements and DBD::Pg

2009-07-14 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: RIPEMD160 It's perfectly valid (from the DBI's point of view) for prepare() to return a prepared statement handle for an invalid statement.

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-08 Thread Tim Bunce
On Thu, May 07, 2009 at 06:08:12PM -0700, David Fetter wrote: On Fri, May 08, 2009 at 01:02:04AM +0100, Tim Bunce wrote: On Thu, May 07, 2009 at 06:50:11AM -0700, David Fetter wrote: On Thu, May 07, 2009 at 02:31:08PM +0100, Tim Bunce wrote: On Thu, May 07, 2009 at 04:54:06AM +1200,

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-08 Thread Daniel Verite
Tim Bunce wrote: So you're okay with breaking previously working, and prefectly valid, DBI code? I think the rationale is that such code was working by virtue of how prepare() was implemented in DBD::Pg, but was not valid nonetheless, as outlined with this example:

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-08 Thread David Fetter
On Fri, May 08, 2009 at 09:44:56AM +0100, Tim Bunce wrote: On Thu, May 07, 2009 at 06:08:12PM -0700, David Fetter wrote: On Fri, May 08, 2009 at 01:02:04AM +0100, Tim Bunce wrote: On Thu, May 07, 2009 at 06:50:11AM -0700, David Fetter wrote: On Thu, May 07, 2009 at 02:31:08PM +0100, Tim

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-08 Thread Tim Bunce
On Fri, May 08, 2009 at 04:02:29PM +0200, Daniel Verite wrote: Tim Bunce wrote: So you're okay with breaking previously working, and prefectly valid, DBI code? I think the rationale is that such code was working by virtue of how prepare() was implemented in DBD::Pg, but was not

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-08 Thread Daniel Verite
Tim Bunce wrote: The example that started this thread was that this valid statement worked: prepare(CREATE TEMP TABLE foo(...); INSERT INTO foo(1, 1); INSERT INTO foo(2, 2);) but this valid statement didn't: prepare( INSERT INTO foo(1, 1); INSERT INTO foo(2, 2);) My

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-08 Thread JP Fletcher
Daniel Verite wrote: Tim Bunce wrote: The example that started this thread was that this valid statement worked: prepare(CREATE TEMP TABLE foo(...); INSERT INTO foo(1, 1); INSERT INTO foo(2, 2);) but this valid statement didn't: prepare( INSERT INTO foo(1, 1);

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-07 Thread Tim Bunce
On Thu, May 07, 2009 at 04:54:06AM +1200, Andrej wrote: 2009/5/7 JP Fletcher jpfle...@ca.afilias.info: Hi, I see different behavior with DBI/DBD::Pg (1.607/2.11.8, pg 8.1) when the first command in a prepared statement is 'CREATE TEMP TABLE'. For instance, this works: my

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-07 Thread David Fetter
On Thu, May 07, 2009 at 02:31:08PM +0100, Tim Bunce wrote: On Thu, May 07, 2009 at 04:54:06AM +1200, Andrej wrote: 2009/5/7 JP Fletcher jpfle...@ca.afilias.info: Hi, I see different behavior with DBI/DBD::Pg (1.607/2.11.8, pg 8.1) when the first command in a prepared statement is

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-07 Thread Tim Bunce
On Thu, May 07, 2009 at 06:50:11AM -0700, David Fetter wrote: On Thu, May 07, 2009 at 02:31:08PM +0100, Tim Bunce wrote: On Thu, May 07, 2009 at 04:54:06AM +1200, Andrej wrote: WARNING: DBD::Pg now (as of version 1.40) uses true prepared statements by sending them to the backend to be

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-07 Thread David Fetter
On Fri, May 08, 2009 at 01:02:04AM +0100, Tim Bunce wrote: On Thu, May 07, 2009 at 06:50:11AM -0700, David Fetter wrote: On Thu, May 07, 2009 at 02:31:08PM +0100, Tim Bunce wrote: On Thu, May 07, 2009 at 04:54:06AM +1200, Andrej wrote: WARNING: DBD::Pg now (as of version 1.40) uses

[GENERAL] prepared statements and DBD::Pg

2009-05-06 Thread JP Fletcher
Hi, I see different behavior with DBI/DBD::Pg (1.607/2.11.8, pg 8.1) when the first command in a prepared statement is 'CREATE TEMP TABLE'. For instance, this works: my $prepare_sql =SQL; CREATE TEMP TABLE foo( id int, user_id int,); INSERT INTO foo(1, 1); INSERT

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-06 Thread Keary Suska
On May 6, 2009, at 9:39 AM, JP Fletcher wrote: Hi, I see different behavior with DBI/DBD::Pg (1.607/2.11.8, pg 8.1) when the first command in a prepared statement is 'CREATE TEMP TABLE'. For instance, this works: my $prepare_sql =SQL; CREATE TEMP TABLE foo( id int, user_id int,);

Re: [GENERAL] prepared statements and DBD::Pg

2009-05-06 Thread Andrej
2009/5/7 JP Fletcher jpfle...@ca.afilias.info: Hi, I see different behavior with DBI/DBD::Pg (1.607/2.11.8, pg 8.1) when the first command in a prepared statement is 'CREATE TEMP TABLE'. For instance, this works: my $prepare_sql =SQL; CREATE TEMP TABLE foo( id int, user_id int,);

[GENERAL] Prepared statements aren't working with parameters with PQexecParams

2008-09-05 Thread Subspace god
The following works executed in the query browser: PREPARE myquery (text) AS INSERT INTO myTable (word) VALUES ($1); EXECUTE myquery('blah'); The following works in C++, executed as two statements with PQexecParams using PQEXECPARAM_FORMAT_BINARY PREPARE myquery AS INSERT INTO myTable (word)

Re: [GENERAL] Prepared statements aren't working with parameters with PQexecParams

2008-09-05 Thread David Wilson
On Fri, Sep 5, 2008 at 2:52 AM, Subspace god [EMAIL PROTECTED] wrote: The following does not work in C++, executed as above, in another session using two subsequent calls to PQexecParams PREPARE myquery (text) AS INSERT INTO myTable (word) VALUES ($1); EXECUTE myquery($1::text); You're

Re: [GENERAL] Prepared Statements

2008-01-16 Thread Janning Vygen
Am Sonntag 13 Januar 2008 00:46:50 schrieb Tom Lane: Kris Jurka [EMAIL PROTECTED] writes: On Thu, 10 Jan 2008, [EMAIL PROTECTED] wrote: What do you mean with longer lifespan? Doesn't the JDBC driver uses the PREPARE Sql Statement and therefore the prepared Statement has the same lifespan

Re: [GENERAL] Prepared Statements

2008-01-12 Thread Kris Jurka
On Thu, 10 Jan 2008, [EMAIL PROTECTED] wrote: ah! So it doesn't help if it's the same statement, it has to be the same object! So DBCP has a statement pool like a map, say MapString, PreparedStatement so it can fetch the reference to already existing prepared Statement by looking at the

Re: [GENERAL] Prepared Statements

2008-01-12 Thread Tom Lane
Kris Jurka [EMAIL PROTECTED] writes: On Thu, 10 Jan 2008, [EMAIL PROTECTED] wrote: What do you mean with longer lifespan? Doesn't the JDBC driver uses the PREPARE Sql Statement and therefore the prepared Statement has the same lifespan as the connection? If so, as connections are pooled and

Re: [GENERAL] Prepared Statements

2008-01-10 Thread mljv
first: thanks a lot for your answer. it already helped me a lot, but i still have some questions: Am Mittwoch, 9. Januar 2008 21:16 schrieb Kris Jurka: On Wed, 9 Jan 2008, [EMAIL PROTECTED] wrote: - I know there is a PREPARE Statement in Postgresql and read the docs. - in PostgresqlJDBC i

Re: [GENERAL] Prepared Statements

2008-01-10 Thread Isak Hansen
On 1/10/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I have not found anything about preparing unnamed statements. What does it mean? Unnamed statements are what the driver uses before it hits the prepareThreshold limit. Once it has determined the statement will be reused many

[GENERAL] Prepared Statements

2008-01-09 Thread mljv
Hi, i am trying to understand Prepared Statements. I am asking because i want to understand the impact of Prepared statements to my application. Actually i use Hibernate, DBCP Connection Pool with Postgresql-JDBC Driver and Postgresql 8.1. - I know there is a PREPARE Statement in Postgresql

Re: [GENERAL] Prepared Statements

2008-01-09 Thread Martin Gainty
-general@postgresql.org Sent: Wednesday, January 09, 2008 2:02 PM Subject: [GENERAL] Prepared Statements Hi, i am trying to understand Prepared Statements. I am asking because i want to understand the impact of Prepared statements to my application. Actually i use Hibernate, DBCP Connection Pool

Re: [GENERAL] Prepared Statements

2008-01-09 Thread Kris Jurka
On Wed, 9 Jan 2008, [EMAIL PROTECTED] wrote: - I know there is a PREPARE Statement in Postgresql and read the docs. - in PostgresqlJDBC i have a prepareThreshold parameter which i left to default of 5. - in DBCP i have a property poolPreparedStatements, set to true. Does ist just configure

[GENERAL] prepared statements suboptimal?

2007-11-07 Thread rihad
Hi, I'm planning to use prepared statements of indefinite lifetime in a daemon that will execute same statements rather frequently in reply to client requests. This link: http://www.postgresql.org/docs/8.3/static/sql-prepare.html has a note on performance: In some situations, the query plan

Re: [GENERAL] prepared statements suboptimal?

2007-11-07 Thread Reg Me Please
Il Wednesday 07 November 2007 12:25:46 rihad ha scritto: I don't understand why postgres couldn't plan this: SELECT foo.e, foo.f FROM foo WHERE pk=$1 AND b=$2 AND status='1' AND c = $3; to be later executed any slower than SELECT foo.e, foo.f FROM foo WHERE pk='abcabc' AND b='13' AND

Re: [GENERAL] prepared statements suboptimal?

2007-11-07 Thread rihad
rihad wrote: Hi, I'm planning to use prepared statements of indefinite lifetime in a daemon that will execute same statements rather frequently in reply to client requests. This link: http://www.postgresql.org/docs/8.3/static/sql-prepare.html has a note on performance: In some situations,

Re: [GENERAL] prepared statements suboptimal?

2007-11-07 Thread Tom Lane
rihad [EMAIL PROTECTED] writes: Aha, thanks for a thorough explanation. Now I understand that while looking for a way to fulfill the query postgres will try hard to pick the one requiring the least number of rows visits. I've skimmed over my queries: almost all of them make use of the

Re: [GENERAL] prepared statements suboptimal?

2007-11-07 Thread Tom Lane
rihad [EMAIL PROTECTED] writes: I don't understand why postgres couldn't plan this: SELECT foo.e, foo.f FROM foo WHERE pk=$1 AND b=$2 AND status='1' AND c = $3; to be later executed any slower than SELECT foo.e, foo.f FROM foo WHERE pk='abcabc' AND b='13' AND status='1' AND c =

Re: [GENERAL] prepared statements suboptimal?

2007-11-07 Thread rihad
Tom Lane wrote: rihad [EMAIL PROTECTED] writes: I don't understand why postgres couldn't plan this: SELECT foo.e, foo.f FROM foo WHERE pk=$1 AND b=$2 AND status='1' AND c = $3; to be later executed any slower than SELECT foo.e, foo.f FROM foo WHERE pk='abcabc' AND b='13' AND status='1'

Re: [GENERAL] prepared statements suboptimal?

2007-11-07 Thread Albe Laurenz
rihad wrote: Hi, I'm planning to use prepared statements of indefinite lifetime in a daemon that will execute same statements rather frequently in reply to client requests. This link: http://www.postgresql.org/docs/8.3/static/sql-prepare.html has a note on performance: In some

[GENERAL] Prepared Statements

2003-10-22 Thread Eric Dahnke
Does anyone know the exact definition of a Prepared Statement? String sql = SELECT count(id) FROM customer; executeQuery(sql); I assume the sql string is a prepared statement? Semantic debate here. - Thx ---(end of broadcast)--- TIP