• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Performance boost CI3

#11
(03-06-2021, 12:32 PM)iRedds Wrote: Be careful. The proposed option can play a cruel joke with you.
This request can be written as
Code:
SELECT *
FROM table
WHERE
(id = 1 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))
OR (id = 2 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))
OR (id = 3 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))
OR (id = 4 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))
OR (id = 5 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))

Depending on the logic of your database, this may conflict with the conditions.
https://www.db-fiddle.com/f/ckHvgzVN2u8a1dtv7GoNMZ/0

Perhaps you'd better use UNION
Thanks, actually in my case it is only "d" that has different values, "id" is the same inside each loop, e.g. for all 4 queries.
Reply

#12
@muuucho,

I'm glad the suggestion worked for you. How much faster did the change make it?
Reply

#13
(03-09-2021, 09:53 AM)php_rocs Wrote: @muuucho,

I'm glad the suggestion worked for you. How much faster did the change make it?
Well, I did some other small improvements at the same time and I almost halved the execution time, I am sure most of that cut came from the IN trick. Thanks!
Reply

#14
@muuucho,

Awesome!! Sure, your welcome. I'm glad that I could help.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.