开发者

Postgresql query in 10 seconds

Is there a way to create a query that will run for exactly ten seconds ? I don't need real data just a way to run a query for a long time so I can test how the system works in that time.

I would prefer not to create a hu开发者_StackOverflow中文版ge table and make a simple select just for this. Any tricks?


pg_sleep:

SELECT pg_sleep(10);

But that will not generate any load on the system if that's your real goal.


SET statement_timeout to '10s';
SELECT 1 FROM pg_class CROSS JOIN pg_class CROSS JOIN pg_class ...; -- be careful ;-)

Note that this will stress CPU and RAM, but not necessarily the disk. If you want to stress the disk, you will probably just have to create a very big table. To do that you could save the results of the query above or from any of the other solutions into a new table (CREATE TABLE AS).


You can also run pgbench with -T switch. So...

pgbench -i -s 10

pgbench -c 10 -T 10

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜