WordPress query very slow on +/- 300k DB entries and 7 INNER JOIN

Realistically: Not every kind of data fits well into the WordPress meta model. Sometimes, you’d be better off making a custom set of tables for your data.

If you have to query against 7 different meta values and a taxonomy, then perhaps a custom post type is not the best way to store your data.

The WordPress model is designed for fast retrieval of posts and their associated meta based on a very limited set of selection results. It supports ways of selecting via meta data, but that is not optimal nor is the data model optimized for it. It’s never going to be “fast” to do so. Not really.

So, if you need to select by a whole lot of different fields which aren’t normal “post” fields, then you might want to just make an entirely new table for your data, with columns for those fields, and proper indexing on them, and so forth. If you’re having to create your own crazy SQL already, then making a new table and managing your own data is likely actually easier than screwing around with a Custom Post Type.

As for security, using the built in wpdb::insert and wpdb:update functions will let you do statements securely and without having to do a whole lot of your own calls to wpdb::prepare or writing a whole lot of your own SQL. They even work with your own custom tables.