0

My Query performance is very very bad. It is taking around.

SELECT t1.from_state_id fromStateId,GROUP_CONCAT(t3.state_name) fromState 
FROM tbl_vendor_workstations as t1  
Left JOIN tbl_states as t3 ON find_in_set(t3.id,t1.from_state_id) 
where t1.vendor_id=1717 and enterprise_user_id=703 
group by t1.id

issue is in that function find_in_set(t3.id,t1.from_state_id)

Column t1.from_state_id: 1,2,3,4,5,...,45147 it contains 50,000 separated by comma

Shadow
  • 33,525
  • 10
  • 51
  • 64
Sucbe Sys
  • 175
  • 1
  • 2
  • 13
  • 3
    If you have a comma separated list as string in a column, with 50,000 items, your schema is broken. Normalise your database. – Bart Friederichs Jun 25 '18 at 12:14
  • 1
    When you take the Denormalization to increase performance to heart. – Farhan Qasim Jun 25 '18 at 12:16
  • @BartFriederichs Please suggest me for normalise it. kindly share any code or reference. it would be really thankful for me. – Sucbe Sys Jun 25 '18 at 12:18
  • 1
    [Google is your friend](https://en.wikipedia.org/wiki/Database_normalization). You probably want some kind of coupling table between `tbl_vendor_workstation` and `t3`. Without full domain description and your schema it's hard to say though. – Bart Friederichs Jun 25 '18 at 12:24

0 Answers0