Ver Mensaje Individual
  #3 (permalink)  
Antiguo 17/02/2014, 15:17
Avatar de Carlangueitor
Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: Performance queries con múltiples JOIN.

Gracias! Efectivamente trabaja mucho más rápido, tarda ~20s, lo cuál tampoco es muy aceptable. Pero me di cuenta (por mi poco conocimiento en bases de datos y SQL) de otra manera de hacerlo.

Código MySQL:
Ver original
  1.     auctions_flight.id,
  2.     auctions_flight.date,
  3.     destinations.code as destination_code,
  4.     destinations.name as destination,
  5.     MAX(auctions_flight.num_seating) as num_seating,
  6.     auctions_flightprice.Price,
  7.     MIN(auctions_flightprice.Price) as price
  8.     auctions_flight
  9.         INNER JOIN
  10.     auctions_flightprice ON auctions_flight.price_id = auctions_flightprice.id
  11.         INNER JOIN
  12.     locations_location AS origins ON auctions_flight.origin_location_id = origins.id
  13.         INNER JOIN
  14.     locations_location AS destinations ON auctions_flight.destination_location_id = destinations.id
  15.     auctions_flight.num_seating >= 3
  16.         AND auctions_flight.price_id IS NOT NULL
  17.         AND auctions_flightprice.currency = 'MXN'
  18.         AND origins.code = 'MEX'
  19.         AND auctions_flight.date >= CURDATE()
  20. GROUP BY auctions_flight.date , auctions_flight.destination_location_id , auctions_flight.origin_location_id
  21. ORDER BY price , auctions_flight.date
  22. LIMIT 0 , 25;

Y hasta ahora funciona adecuadamente y a buen tiempo ~0.1s.


Saludos
__________________
Grupo Telegram Docker en Español