Question: I am working on a space exploration and combat game, and I can create galaxies, nebulas, solar systems, and load and unload them procedurally as needed. Meaning the stars that the player can see are exactly where they are. I have a coordinate system set up with meter-precision, meaning it's sufficient to map quite several galaxies, but also tiny missiles.

For now, I created a galaxy with 10.000.000 solar systems, and my SQLite database reached 5gb. It takes ~30 minutes to generate it, and I notice a slow-down as the size of the database increases in loading times. I did a lot of optimization, and while everything is running fine and well now, I seek to reach 200-300m solar systems if possible. The database would be stored locally on the user's drive, rather than downloaded from a server. I use a GlobalX/Y/Z (int64) and LocalX/Y/Z (double) for coordinates, and only the GlobalX/Y/Z is used to find large objects like stars and planets (I also use multiple chunk systems).

[Elite Dangerous manages to store the data of 400 *billion*](https://elite-dangerous.fandom.com/wiki/Galaxy) solar systems and has no issues with loading times, somehow. How can they display many stars in the background? How do they manage to store a lot more data than I already do?

For now, my data is quite minimalistic and comparatively minuscule in number, but they must have quite a lot of data for each stellar object even. What technical "tricks" can I employ to solve this problem in my game?

Answer: 
In addition to the points that have been made about not actually generating all the data there's another factor: You can't actually draw 10,000,000 stars. Nobody has a display that can handle it. Therefore, there's no need to have 10,000,000 stars loaded.

Select X, Y, Brightness, Color, ID from StarTable Where X > CurrentX - 200ly And X < CurrentX + 200ly And Y > CurrentY - 200ly And Y < CurrentY + 200ly.

Select X, Y, Brightness, Color, ID from BrightStarTable Where X > CurrentX - 2000ly And X < CurrentX + 2000ly And Y > CurrentY - 2000ly And Y < CurrentY + 2000ly.

That will be a tiny fraction of your total stars, but it is sufficient to draw anything you can see out the window of your starship. I would store all the details on the stars in a separate table accessed by the StarID as you only need those details when examining a particular star.

You can cut the loaded data down even more by having a DimStarTable with an even shorter query range. Most stars will be in this table.

Another option also comes to mind: Define a new variable: Sector. Sector = (int)(x/100ly) + (int)(y/100ly) \* 10000. You load the sector you are in and the 8 adjoining sectors. The select would run faster. (Likewise, the bright star table would have 1000ly sectors.)
If you have a deterministic algorithm that uses a seed, like how PRNG's work, you can store almost nothing and generate the star's positions on the fly, only keeping those that you currently need. Think how demoscene demos work.