Optimized Select Statement
| От | Yan Cheng Cheok |
|---|---|
| Тема | Optimized Select Statement |
| Дата | |
| Msg-id | 1893.70905.qm@web65716.mail.ac4.yahoo.com обсуждение |
| Ответ на | Re: PostgreSQL Write Performance (Simon Riggs <simon@2ndQuadrant.com>) |
| Ответы |
Re: Optimized Select Statement
|
| Список | pgsql-general |
I am having the table with 1 million rows.
I know there can be multiple "YanChengCHEOK". But in certain situation, I will be only interested in 1 "YanChengCHEOK".
I try to perform SELECT query.
SemiconductorInspection=# SELECT measurement_type_id FROM measurement_type WHERE measurement_type_name='YanChengCHEOK';
measurement_type_id
---------------------
1
(1 row)
Time: 331.057 ms
I try to have it in stored procedures.
DECLARE
_measurement_type_id int8;
BEGIN
SELECT measurement_type_id INTO _measurement_type_id FROM measurement_type WHERE
measurement_type_name='YanChengCHEOK';
RAISE NOTICE '%', _measurement_type_id;
return 1;
end;
It tools me only 1.018ms
High chance that PostgreSQL stop looking further, when it found that the variable int8 had been fill in with at most 1
value.
Without using stored procedure, how can I send a SQL statement to PostgreSQL, to tell it that I need only 1
measurement_type_id,to speed up the SELECT speed.
Thanks and Regards
Yan Cheng CHEOK
В списке pgsql-general по дате отправления: