Colleague Martin Berger posted this recently

image

and it got me thinking: If we take out the network (by running a program locally on the database server) how many requests per second can a modern but affordable/consumer level PC do?

After all, I’ve lost track of the number of posts I see on social media where people are saying you must create a 128-node distributed cluster of machines in order to handle 100 requests per second.

Now I must stress – I’m not claiming any “benchmark level rigour” here. This is solely my curiosity on how many concurrent requests my database can handle by making those requests as basic as possible.

Thus I’m doing the bare minimum here – a simple SELECT from DUAL, and iterating over this call 200,000 times in a Java program.

Quick screen shot of the source below and if you are excessively enthusiastic 🙂 and want to run this yourself you can grab the source here

image

On Windows, it is easy to throw together a quick batch script to launch a bunch of concurrent executions of a program


set CLASSPATH=C:\oracle\jdbc236\ojdbc17.jar;.
start java SimpleDual2
start java SimpleDual2
start java SimpleDual2
start java SimpleDual2
start java SimpleDual2
start java SimpleDual2
...
...

After tinkering with the number of concurrent executions, the sweet spot came out around 14 (unsurprising given my machine has 20 cores in total, 8 performance cores and 12 efficiency cores), and the elapsed time for 14 concurrent executions averaged 11.3 seconds.

A little bit of math yields

14 jobs * 200,000 requests / 11.3 seconds = ~240,000 requests per second!

If you’re thinking (like I was)  “Wow!” then remember that even though we have eliminated the network transmission cost, we are still incurring the cost of having the database “respond” to a request coming from an external program.

What if we moved that request inside the database, ie, we ran all those requests in PL/SQL?  That’s easy to do


set timing on
declare
  x int;
begin
  for i in 1 .. 500000 loop
    select 1 into x from dual;
  end loop;
end;
/

Notice I’ve bumped up the iteration count to 500,000. That’s probably a hint that this was so fast I had to bump up the numbers to get reasonable timing!

The results?

14 jobs * 500,000 requests / 6.2 seconds = ~1,130,000 requests per second!

All on a home PC which by the way, like most people, had the usual 30 browser tabs open whilst the benchmarks were running 🙂

Modern computers are just insanely powerful. From someone who began their Oracle database work on a Sun Sparc 10 running at 33Mhz, I have to keep telling myself “We ain’t in Kansas anymore”

6 responses to “Smashing a database on my PC”

  1. aminaa49ed2e27e Avatar
    aminaa49ed2e27e


    And to think the Powers-that-be stopped the use of PL/SQL in the database — because we had more Java people in the group.

  2. I don’t usually have a database running on my laptop, but I do have a small PC with a desktop CPU and NVME disks.

    The CPU is 13th Gen Intel(R) Core(TM) i7-13700K

    smash-db is a small C program that runs ‘select 1 mynum from dual’ as many times as required

    $ ./smash-db scott tiger mymachine/orcl1901 1000000
    Elapsed time for 1000000 executions: 8.837 seconds
    Fetches per second: 113161.760
    Seconds per fetch: 0.000009

    1. computers are just scary quick nowadays

      1. I ran 50 concurrently: 1,487,881 fetches per second

        It is quite amazing. What we could have done with these 30 years ago. 🙂

  3. James Phillips Avatar
    James Phillips

    Hello. How would I run this on an OEL server, but outside the database? Create a Jar file and execute that?
    If that’s the case do you happen to have the java code for something like that?

    1. You’ll need
      – the java source (from the post)
      – an instant client (to get ojdbc17.jar) https://www.oracle.com/au/database/technologies/instant-client/downloads.html
      – a JDK (there is probably already one on the server)
      and you should be good to go

Leave a Reply to Connor McDonaldCancel reply

Trending

Discover more from Learning is not a spectator sport

Subscribe now to keep reading and get access to the full archive.

Continue reading