IT Base of Knowledge's Weblog

November 11, 2009

Find duplicate in a database

Filed under: Uncategorized — itbdc @ 7:10 pm


SELECT my_key, count(*) FROM my_table GROUP BY my_key HAVING count(*) > 1;

November 5, 2009

Insert timestamps with a loop

Filed under: Database,PostgreSQL — itbdc @ 9:18 am

This sql command allow you to test data writting in your database. It can be useful to benchmark your disk performances or check the impact of a lock.


INSERT INTO table SELECT timeofday()::timestamp FROM generate_series(1,1000000) WHERE pg_sleep(1) IS NOT NULL;

Blog at WordPress.com.