Open amyAMeQ opened 2 weeks ago
Hi @amyAMeQ
thanks for the report, you're totally right about this, it could be improved.
Problem is: I think it is not the same syntax between mysql (ORDER BY RAND()
) and postgresql (ORDER BY RANDOM()
)
We're about to release Foundry 2.0, certainly the next week. I'd rather this to be fixed in 2.0 than in 1.x
@nikophil - OK. I will pull the 2.0 branch and play locally. Hoping I can find a way to do it in a database agnostic way.
you'll find an upgrade guide here: https://github.com/zenstruck/foundry/blob/1.x/UPGRADE-2.0.md (not 100% up to date)
BTW don't hesitate to report any problems you'd find in 2.x branch :sweat_smile:
While diagnosing why some of our tests are so slow, I discovered the culprit for us is with random(). We have a function:
And it was making tests take five times as long as when we didn't use it.
After poking around, I noticed that rather than getting X random records, it's getting ALL of them and then getting random ones from that.
I think it would be more performant if the code used something like this to just get random records from the database (with the appropriate attribute filters):
I am willing to do a PR for this if you would like.