parsed.org

Tips by tag: performance

Booleans In The WHERE Clause by xinu on May 03, 2005 05:21 PM

If you're going to use a boolean condition in your where clause, you're going to want to make sure you use an operator so that the index is used (if present).

For example, this will not use the index:

db=> SELECT id FROM users WHERE active;

This will use the index:

db=> SELECT id FROM users WHERE active = true;
expressionsgotchaindexperformancepostgresqlsql

Use the form ::type to ensure that a value is cast to the proper type:

SELECT * FROM table WHERE column = 5::bigint;

In this case, column is indexed and is a bigint. The index will not be used if the query planner doesn't encounter a value of the index type. Note: this only applies in PostgreSQL 7.x.

gotchaindexperformancepostgresqlsqlsyntaxtypes
Eliminating Aggregates by cygnus on Mar 31, 2005 08:49 AM

If you have a query like this:

SELECT max(some_column) FROM mytable WHERE ...;

and you want to eliminate the sequence scan that kills the query's performance, an alternative is:

SELECT some_column FROM mytable WHERE ... ORDER BY some_column DESC LIMIT 1;

MIN and MAX aggregates can be eliminated this way.

aggregatesmaxminperformancepostgresqlqueriesscansql
Optimize Firefox for Broadband by xinu on Jan 12, 2005 01:37 PM

Open about:config in a new tab and make the following changes:

network.http.pipelining -> True
network.http.pipelining.maxrequests -> 10

Anywhere on the screen, right-click and add a new integer:

nglayout.initialpaint.delay -> 0

If you're using a proxy, also change the proxy versions:

network.http.pipelining.proxy.pipelining -> True

WARNING: Be conservative when setting your pipelining settings. To the untrained eye this feature looks like a DOS attempt on the server side and might get you blocked.

browserconfigurationfirefoxgotchanetworkperformance
Query performance analysis by cygnus on Jan 12, 2005 10:14 AM

Use explain:

EXPLAIN SELECT * FROM some_table WHERE condition;
analysisexplainperformancepostgresqlsql
Query Timing by xinu on Jan 19, 2005 09:43 AM

If you want to see how long a query is taking to run, you can either run explain analyze or enable timing for the client by typing \timing.

analysisconfigurationdebuggingdurationoutputperformancepostgresqlpsqlruntimesqltiming
RSS