Database Reference
In-Depth Information
(7 rows)
Time: 763.513 ms
Spending almost a second getting seven messages seems slow, so we need to op-
timize a bit.
The first thing to do is to add indexes for retrieving the messages:
hannu=# CREATE INDEX message_from_user_ndx ON
message(from_user);
CREATE INDEX
Time: 4341.890 ms
hannu=# CREATE INDEX message_to_user_ndx ON
message(to_user);
CREATE INDEX
Time: 4340.841 ms
And check if this helped to solve our problem:
hannu=# select get_new_messages('52000');
get_new_messages
----------------------------------------------------------
(200,"hello friend!",51993,"2012-01-09
02:23:28.470979")
(200,"hello friend!",51994,"2012-01-09
02:23:28.470979")
(200,"hello friend!",51996,"2012-01-09
02:23:28.470979")
(200,"hello friend!",51997,"2012-01-09
02:23:28.470979")
(200,"hello friend!",51998,"2012-01-09
02:23:28.470979")
(200,"hello friend!",51999,"2012-01-09
02:23:28.470979")
(200,"hello friend!",52000,"2012-01-09
Search WWH ::




Custom Search