Results 1 to 3 of 3

Thread: table count

  1. #1
    Join Date
    Jul 2003
    Posts
    1

    Unanswered: table count

    hi,

    is it normal that when i issue a "select count(*) from <table>" command postgres performs a sequential scan in order to evaluate the number of items in that table? i have a table with almost 3 million entires and the operations takes several seconds to complete. the server has plenty of ram and is fast enough.

    koxuz

  2. #2
    Join Date
    Sep 2001
    Location
    Vienna
    Posts
    400

    count

    this is a well known problem in postgresql

    this has to be I think of some transactional reasons

    but there are attempts to getting rid of this seq scan
    http://www.postgresql.org
    --Postgresql is the only kind of thing--

  3. #3
    Join Date
    Apr 2003
    Location
    Tunisia
    Posts
    192

    Thumbs up Try this

    In order to to get fatsre reponse you could shorten you query by just counting one row select count(row) from <table>, or just get the max of the id if u have a regular counter , or just create a row updated with a trigger (on upsdte/insert/delete) that saves the number of rows.

    Good Luck !
    Open up
    Take a look to my Blog http://www.rundom.com/karim2k

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •