On Sep 16, 3:18 pm, Michael Granger <[email protected]> wrote:
> Joe Van Dyk wrote:
> > Fromhttp://sequel.rubyforge.org/rdoc/files/doc/prepared_statements_rdoc.html
>
> > "PostgreSQL
> > If you are using the ruby-postgres or postgres-pr driver, PostgreSQL
> > uses the default emulated support. If you are using ruby-pg, there is
> > native support, but it may require type specifiers. This is easy if
> > you have direct control over the SQL string, but since Sequel
> > abstracts that, the types can be specified another way. This is done
> > by adding a __* suffix to the placeholder symbol (e.g. :$name__text,
> > which will be compiled to $1::text in the SQL). Prepared statements
> > are always server side."
>
> > What's meant by "default emulated support"?
>
> At the very bottom of that page it says:
>
> All Others
> Support is emulated using interpolation.
>
> I think that's what it's referring to.
I have the following:
DB[:orders].
filter(:email_address => :$email__text).
prepare(:select, :select_by_email_with_type)
DB[:orders].
filter(:email_address => :$email).
prepare(:select, :select_by_email_without_type)
DB.call(:select_by_email_with_type, :email => "[email protected]")
DB.call(:select_by_email_without_type, :email => "[email protected]")
Here's the postgresql.log:
LOG: duration: 1.724 ms parse select_by_email_with_type: SELECT *
FROM "orders" WHERE ("email_address" = $1::text)
LOG: duration: 0.038 ms bind select_by_email_with_type: SELECT *
FROM "orders" WHERE ("email_address" = $1::text)
DETAIL: parameters: $1 = '[email protected]'
LOG: duration: 0.037 ms execute select_by_email_with_type: SELECT *
FROM "orders" WHERE ("email_address" = $1::text)
DETAIL: parameters: $1 = '[email protected]'
LOG: duration: 0.173 ms parse select_by_email_without_type: SELECT *
FROM "orders" WHERE ("email_address" = $1)
LOG: duration: 0.029 ms bind select_by_email_without_type: SELECT *
FROM "orders" WHERE ("email_address" = $1)
DETAIL: parameters: $1 = '[email protected]'
LOG: duration: 0.007 ms execute select_by_email_without_type: SELECT
* FROM "orders" WHERE ("email_address" = $1)
DETAIL: parameters: $1 = '[email protected]'
Other than '$1::text', I don't see a difference. Should I be?
Joe
LOG: duration: 1.709 ms parse select_by_email_with_type: SELECT *
FROM "orders" WHERE ("email_address" = $1::text)
LOG: duration: 0.073 ms bind select_by_email_with_type: SELECT *
FROM "orders" WHERE ("email_address" = $1::text)
DETAIL: parameters: $1 = '[email protected]'
LOG: duration: 0.060 ms execute select_by_email_with_type: SELECT *
FROM "orders" WHERE ("email_address" = $1::text)
DETAIL: parameters: $1 = '[email protected]'
LOG: duration: 0.279 ms parse select_by_email_without_type: SELECT *
FROM "orders" WHERE ("email_address" = $1)
LOG: duration: 0.029 ms bind select_by_email_without_type: SELECT *
FROM "orders" WHERE ("email_address" = $1)
DETAIL: parameters: $1 = '[email protected]'
LOG: duration: 0.008 ms execute select_by_email_without_type: SELECT
* FROM "orders" WHERE ("email_address" = $1)
DETAIL: parameters: $1 = '[email protected]'
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.