I have a huge table in my database (MySQL)with millions of data. I need to populate 10 random data and show it on the UI. What would be a good approach considering performance?
I was thinking about creating MySQL View to populate 10 random rows and read it from UI. Or is there any other efficient way to handle this situation?
First of all (it’s my proper opinion) i’m against using raw SQL when we are already working with a hight level framework like Django unless we don’t find what we are looking for in the framework (Django) , so i will rather use Django for this matter:
remark this approach it’s only working if you have set auto increment to you PK and of course if you data is consistent (you don’t remove record from the table so that you can be sure that all ids are auto incremented)
if the condition sited before are not satisfied i think you can do it with an raw SQL query like this:
about performance i think you have to timeit, Hope this will help.