Re: Is there any method to keep table in memory at startup

From: Andrew Hammond <ahammond(at)ca(dot)afilias(dot)info>
To: vinayj(at)ncst(dot)ernet(dot)in
Cc: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is there any method to keep table in memory at startup
Date: 2004-04-28 13:28:08
Message-ID: 408FB168.7020500@ca.afilias.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Vinay Jain wrote:
> Hi
> thank you for such a useful information...
> but actually in my case if i keep table in disk it significantly
> degrades performance and even for a table of 10 rows it takes 1-2
> minutes I think u r not beliving it ! am i right
> for example
> I create a table in which i use my customized data type say student
> create table student
> (Name INDCHAR //INDCHAR is customized data type
> age integer);
> now i give query like this
> select * from student order by name;
> it will search for it's comparator operator (<) and related function...
> in that function there is one lookup table if that table is in memory no
> problem! (oh but it can't be) if it is in disk my program makes
> connection to database and execute query which is just a select
> statement on a simple where condition of equality. then closes connection

There's your problem. Creating database connections is an expensive
operation. They are not intended to be opened and closed often or
quickly. Open your database connection at the beginning of your program,
and close it at the end.

You could also throw an index on the column you're using in your order
by clause, but that won't make a difference until your table get a
little bigger.

Please take further questions of this nature to the pgsql-novice list.

> so every time less than operator(<) is called it does the same task..
> what i feel in table of 10 rows how many times the < operator will be
> called(NO idea but must be > 10 times)
> is there any solution..
> thanks in advance
> regards
> vinay

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2004-04-28 13:40:06 Re: pg ANY/SOME ambiguity wrt sql standard?
Previous Message Fabien COELHO 2004-04-28 13:21:00 pg ANY/SOME ambiguity wrt sql standard?