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

Hola,

Tengo una consulta, no muy grande y hasta donde entiendo no debería ser tan ineficaz. Actualmente tarda ~110s, la tabla no contiene muchos registros (200k), lo que supongo que el problema está en el subquery, ¿alguna sugerencia?

Código MySQL:
Ver original
  1.     auctions_flight.id,
  2.     auctions_flight.`date`,
  3.     origins.code as origin_code,
  4.     origins.name as origin,
  5.     destinations.name as destination,
  6.     destinations.code as destination_code,
  7.     auctions_flight.num_seating,
  8.     auctions_flightprice.Price,
  9.     auctions_flightprice.currency
  10.     auctions_flight
  11.         INNER JOIN
  12.     auctions_flightprice ON auctions_flight.price_id = auctions_flightprice.id
  13.         INNER JOIN
  14.     locations_location as destinations ON auctions_flight.destination_location_id = destinations.id
  15.         INNER JOIN
  16.     locations_location as origins ON auctions_flight.origin_location_id = origins.id
  17.     auctions_flight.num_seating >= 3
  18.         AND origins.code = 'MEX'
  19.         AND auctions_flightprice.currency = 'MXN'
  20.         AND auctions_flightprice.Price = (SELECT
  21.             MIN(Price)
  22.         FROM
  23.             auctions_flightprice
  24.         WHERE
  25.             origin_location_id = auctions_flight.origin_location_id
  26.                 AND destination_location_id = auctions_flight.destination_location_id
  27.                 AND `date` = auctions_flight.`date`)
  28. ORDER BY auctions_flightprice.`Price`
  29. LIMIT 25;

Saludos.
__________________
Grupo Telegram Docker en Español