We log values and we only log them once in a table. When we add values to the table we have to do a look up everytime to see if it needs to insert the value or just grab the id. We have an index on the table (not on the primary key) but there are about 350,000 rows (so it is taking 10 seconds to do 10 of these values).
So either
- We figure out a way to optimize it
- Strip it this feature out or
- Do something completely different when logging these values.
How frequently do you write to the table vs. reading from it. If you have frequent writes and occasional reads, consider just always doing inserts and then handle collapsing the values when doing a select.
If you’re trying to put everything in one table, consider breaking them out into separate tables to cut down on size, or barring that use partitions on the table.