libpq very slow for large database
===

I am new to SQL/DBMS.

I have an application which adds rows with 10 columns in postgre server using libpq library. Right now, my server is running on same machine as my visual c++ application.

I have added around 15-20millions of data. The simple query of getting total count is taking 4-5mins (select count(*) from <tableName>;).

I have indexed my table with the time I am entering the data (timecode). Most of te times I need count with different "ands" and "wheres" added.

Is there any way to make things fast? I need to make it as fast as possible because once the server moves to network, things will become much slower.

Thanks