O'Reilly logo

PostgreSQL 9.0 High Performance by Gregory Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Executing other statement types

The same basic execution logic is used to handle all four of the basic SQL query types: SELECT, INSERT, UPDATE, and DELETE. For example, when doing an UPDATE, the identified rows to update are found in a familiar way and then fed to an Update node:

EXPLAIN ANALYZE UPDATE customers SET state=state WHERE customerid=1;
QUERY PLAN
----------
Update  (cost=0.00..0.28 rows=1 width=274) (actual time=63.289..63.289 rows=0 loops=1)
   ->  Index Scan using customers_pkey on customers  (cost=0.00..0.28 rows=1 width=274) (actual time=0.054..0.063 rows=1 loop
s=1)
         Index Cond: (customerid = 1)
 Total runtime: 63.415 ms

UPDATE and DELETE can execute efficiently by keeping track of the tuple ID uniquely identifying each of the rows ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required