Re: Query performance on session table
[Please don't top post as it makes the discussion more difficult to
follow.]
.... and I thought I was an experienced web user... My apologies.
The times you're probably
interested in are of the sort
SELECT *
FROM session
WHERE session_id = ?;
This query is really fast as you can see in my original post.
Also, you should be looking at your app to see what
queries are actually being run against session and how they perform
rather than using SELECT * FROM session as a benchmark (unless SELECT
* FROM session *is* a critical query for your app)
The garbage collector (DELETE FROM session WHERE session_expires <
timestamp) has to do the same sequential scan.
# EXPLAIN ANALYZE DELETE FROM session WHERE session_expires<0;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------
Seq Scan on session (cost=0.00..147919.91 rows=1 width=6) (actual
time=1473.284..1473.284 rows=0 loops=1)
Filter: (session_expires < 0)
Total runtime: 1473.315 ms
(3 rows)
On a side note however, without me doing anything the results has
changed even though pg_stat_activity table shows the same amount of
activity.
# EXPLAIN ANALYZE SELECT * FROM session;
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------
Seq Scan on session (cost=0.00..147917.93 rows=793 width=282)
(actual time=1519.959..1612.596 rows=672 loops=1)
Total runtime: 1613.248 ms
(2 rows)
672 rows in 1.6 secs... I guess I am looking at the wrong place.
Thank you for you input.
Burak
Home |
Main Index |
Thread Index