Most databases are smart at planning queries and will use statistical information from the actual data to do so.
Therefore, if you use a test database with generated dummy data, it is absolutely essential that the size and statistical distribution of this dummy data be a good representation of real world data.
If you test for a small dataset that is not representative of your real data... you will get query plans optimized for your test dataset, which can completely miss the mark. Ironically, the smarter the database, the worse it gets, because query plans can be wildly different depending on data size and statistics.
Example 1: Geographic search
If you generate test data that with random uniform distribution, it is not representative. Searching for points within an area of a certain size will always give more or less the same number of results. In the real world, there are very dense cities and vast empty areas. A better statistical distribution modeling this would allow you to catch performance problems like using a bounding box that is too large on an area that is too densely populated with results.
Example 2: Forum
Likewise if test data is generated with an uniform distribution, with all topics having more or less the same number of posts, you will miss the typical runaway topic with thousands of pages. If it is paginated with a naive "ORDER BY timestamp OFFSET..." it has to scan the whole tens of thousands of posts and skip them in order to display the last one. This also kills your cache. So the most frequently displayed page (the last one) is the slowest, and the topic in question is the one with highest traffic, which is a recipe for bad performance.
In this case it could have been caught earlier by thinking a little bit more: the developer's efforts should be focused on making the most frequently displayed pages (first and last) the fastest, and it's okay if page 500 in a 1000 pages topic is slow to display because no-one will ever display it. In this real world case, the solution was to switch the ORDER BY from ASC to DESC depending on the page number, and tweak OFFSET/LIMIT values accordingly. So for the last page, it would scan the (topic_id, timestamp) index starting from the end, resulting in "OFFSET 0" for the last page, no rows skipped, no cache pollution, and much higher performance.
It's important to add some outliers in the test data, if you have groups or categories there should be one with a much larger size than the others.
If you have TEXT or binary fields allowing near-unlimited length, then these should not all contain "Hello, world" but instead a representative sample of text lengths. Especially if you want to test fulltext search.
The test server should not be overpowered. In fact, if you test with a single user, having an overpowered test server can be misleading, because in real use, server resources are shared between all users. So if it has too much RAM and SSDs, everything's going to be too fast!
If you work on a website, it really helps to have a "developer mode" which displays all the queries done for the page at the bottom, along with timings. The way I implemented it was to allow users with admin rights to impersonate a normal user, so they would see the website exactly as seen by users, plus the query log and other performance information at the bottom of the page.