Re: Query preparation
От | John Lister |
---|---|
Тема | Re: Query preparation |
Дата | |
Msg-id | 49E4C586.4070107@kickstone.com обсуждение исходный текст |
Ответ на | Re: Query preparation (Oliver Jowett <oliver@opencloud.com>) |
Ответы |
Re: Query preparation
Re: Query preparation |
Список | pgsql-jdbc |
Oliver Jowett wrote > John Lister wrote: > >> Hi, i was wondering if there is any reason why the query preparation is >> done when the query is executed instead of when the preparedStatement is >> created. >> > > It would be an extra network round-trip on every query, and there's no > requirement to prepare it early. > > I'm not sure why it would be there would be an extra round trip? The parse is done anyway, the only extra round trip would be if you did a describe (which admittedly i'm looking into optionally doing for binary transfers) or if you didn't use the preparedStatement to do any queries which is i'd imagine is rare. Maybe i've missed something? >> Has any one looked into moving it? >> > > Why would you want to move it? > > To me it would be cleaner, it looks like the current driver was written prior to v3 of the protocol where only simple queries are used and everything is transmitted as text. The extended protocol stuff has been bolted subsequently to the execute part of the driver rather than doing it when the query is prepared... btw, i have nothing but respect for the writers after doing some work on the another driver some years ago. Also, in fairness i've done a lot of work with the oracle stuff vwhich create portals (cursors) and prepare the statement before the execution and this makes more sense to me. Also, with regard to extra network traffic and latency i'm not suggesting changing the way normal statements are used, only PreparedStatements. This to me fits in more with the way the JDBC spec is worded and i'd guess the more usual use case of statements - Statement for quick and dirty one off queries, PreparedStatement for more complicated/multiple use queries. JOHN
В списке pgsql-jdbc по дате отправления: