I have a database that stores unordered user-collected data in the following format:
uID format value
ash001 height 37
ash001 disease green
ash002 disease red
ash003 disease orange
ash003 height 39
When exporting, users prefer the following data format:
uID height disease
ash001 37 green
ash002 red
ash003 39 orange
Exporting the values from the database format to a CSV file is relatively simple and causes no issues. When I try to export the user-preferred format, I quickly run into performance issues. My current approach for organizing and exporting is to get a list of the different 'formats' and 'uIDs' and then perform single queries to obtain each 'value' to fill the table. This leads to many queries (often with empty values) and very sluggish performance. The max uIDs and formats I've observed was 9000x20.
I'm interested in finding a better approach that would speed up the export process.