PHP PDO->bindValue() vs row execute speed difference

Поиск
Список
Период
Сортировка
От Georgi Ivanov
Тема PHP PDO->bindValue() vs row execute speed difference
Дата
Msg-id AANLkTinpeZEzEBFhi-2iZ6FM9p-HtTvkVrPAgK6MPqRD@mail.gmail.com
обсуждение исходный текст
Ответы Re: PHP PDO->bindValue() vs row execute speed difference  (Cédric Villemain <cedric.villemain.debian@gmail.com>)
Список pgsql-general
Hi,
I have following situation:
$q = 'select * from tbl1 where id = :id';
$stmt = $dbh->prepare($q);
$stmt->bindValue(':id', $id , PDO::PARAM_INT);
$stmt->execute();
//1000 ms
and

$q1 = ' select * from tbl1 where id = 100 ';
$stmt = $dbh->prepare($q);
//NO binding here !
$stmt->execute();
//2 ms

The queries are a bit more complex, but this is enough to get the idea.

So the first query runs for about 1000 ms

The second query( w/o binding) runs for about 2 ms.
If I'm correct, the first query is interpreted as : select * from tbl1 where id = (INT )
and I don't get good execution plan.

The second one is fast, because  the DB see the literal 100 as value for ID and makes a better execution plan.
Am I correct in my thoughts ?
Is there anything I can do in tuning the DB or just to skip/rewrite PHP PDO ?

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

Предыдущее
От: Guillaume Lelarge
Дата:
Сообщение: Re: pgAdmin 3 index display problem
Следующее
От: Stefan Schwarzer
Дата:
Сообщение: Re: Problem with Crosstab (Concatenate Problem)