EDIT FINAL: 変更されたコードは 5.5 で動作しますが、5.0 では少し異なる行セットが得られます。
次のクエリ
SELECT DISTINCT
sql_no_cache as job.id,
job.id as job_id,
job.job_status,
job.servee_name,
kase.plaintiff,
index_number,
lawfirm_filenumber,
DATE_FORMAT(job.datetime_received, '%m/%d/%Y') as date_received,
DATE_FORMAT(job.date_sent_to_court, '%m/%d/%Y') as date_sent_to_court,
DATE_FORMAT(kase.date_kase_filed, '%m/%d/%Y') as date_kase_filed,
TO_DAYS(NOW())-TO_DAYS(kase.date_kase_filed) as thedays,
DATE_FORMAT(kase.court_datetime, '%m/%d/%Y %h:%i %p') as court_date,
kase.court_room,
CONCAT( LUcourt.court_county," - ",LUcourt.court_type) as court_name,
DATE_FORMAT( job.datetime_served, '%m/%d/%Y') as datetime_served,
CONCAT( server.namefirst,' ', server.namelast) as server_name
FROM job
LEFT JOIN kase ON job.kase_id = kase.id
LEFT JOIN kasebilling ON kasebilling.kase_id = kase.id
LEFT JOIN server ON job.server_id = server.id
LEFT JOIN client ON client.id = kase.client_id
LEFT JOIN LUcourt ON LUcourt.id = kase.court_id
WHERE job.subscriber_id = 1
ORDER BY job_id + 0
LIMIT 0,500;
</pre>
i modified the query but it wont run ...
SELECT DISTINCT sql_no_cache job.id, job.id as job_id, job.job_status, job.servee_name, kase.plaintiff, index_number, lawfirm_filenumber, DATE_FORMAT(job.datetime_received, '%m/%d/%Y') as date_received, DATE_FORMAT(job.date_sent_to_court, '%m/%d/%Y') as date_sent_to_court, DATE_FORMAT(kase.date_kase_filed, '%m/%d/%Y') as date_kase_filed, TO_DAYS(NOW())-TO_DAYS(kase.date_kase_filed) as thedays, DATE_FORMAT(kase.court_datetime, '%m/%d/%Y %h:%i %p') as court_date, kase.court_room, CONCAT(LUcourt.court_county," - ",LUcourt.court_type) as court_name, DATE_FORMAT(job.datetime_served, '%m/%d/%Y') as datetime_served, concat(server.namefirst,' ', server.namelast) as server_name FROM job
LEFT JOIN kase ON job.kase_id = kase.id
LEFT JOIN kasebilling ON kasebilling.kase_id = kase.id
LEFT JOIN server ON job.server_id = server.id
left join client on client.id=kase.client_id
left join LUcourt on LUcourt.id=kase.court_id WHERE job.subscriber_id = 1 and job_id in (select distinct job.id from job where job.subscriber_id = '1' order by id+0) LIMIT 0,500
</pre>
上記のクエリを変更して、テーブル名の一部を削除しました...ただし、クエリで注文を削除すると、非常に高速になります...制限500だけでなく、すべての行で注文すると思います... どうすれば order by でこれをより速く動作させることができますか。どんな助けでも感謝します....
PS:order_byでファイルソートを使用しています...
説明:
+----+-------------+-------------+--------+------- -------------------------------------------------- ------------------------------+-------------------------------- --------------+---------------------+-------------- ------+--------------------+---------------------------------------------- ---------------+ | | ID | select_type | テーブル | タイプ | 可能な_キー | キー | key_len | 参照 | 行 | 行 エクストラ | +----+-------------+-------------+--------+------- -------------------------------------------------- ------------------------------+-------------------------------- --------------+---------------------+-------------- ------+--------------------+---------------------------------------------- ---------------+ | | 1 | シンプル | 仕事 | 仕事 | 参照 | Subscriber_id,subscriber_id-job_loc-client_loc-server_loc,sub_id_idx_serve_name_idx | subscriber_id-job_loc-client_loc-server_loc | 4 | 定数 | 362381 | where を使用します。一時的な使用; ファイルソートの使用 | | | 1 | シンプル | かせ | eq_ref | プライマリ | プライマリ | 4 | pserve.job.kase_id | 1 | | | | | 1 | シンプル | カセビリング | 参照 | kase_id | kase_id | 4 | pserve.kase.id | 2 | インデックスの使用 | | | 1 | シンプル | サーバー | eq_ref | プライマリ | プライマリ | 4 | pserve.job.server_id | 1 | | | | | 1 | シンプル | クライアント | eq_ref | プライマリ | プライマリ | 4 | pserve.kase.client_id | 1 | インデックスの使用 | | | 1 | シンプル | ルクール | eq_ref | プライマリ | プライマリ | 4 | pserve.kase.court_id | 1 | | | +----+-------------+-------------+--------+------- -------------------------------------------------- ------------------------------+-------------------------------- --------------+---------------------+-------------- ------+--------------------+---------------------------------------------- ---------------+
クエリを変更しましたが、実行されません...
SELECT DISTINCT sql_no_cache job.id, job.id as job_id, job.job_status, job.servee_name, kase.plaintiff, index_number, lawfirm_filenumber, DATE_FORMAT(job.datetime_received, '%m/%d/%Y') as date_received, DATE_FORMAT(job.date_sent_to_court, '%m/%d/%Y') as date_sent_to_court, DATE_FORMAT(kase.date_kase_filed, '%m/%d/%Y') as date_kase_filed, TO_DAYS(NOW())-TO_DAYS(kase.date_kase_filed) as thedays, DATE_FORMAT(kase.court_datetime, '%m/%d/%Y %h:%i %p') as court_date, kase.court_room, CONCAT(LUcourt.court_county," - ",LUcourt.court_type) as court_name, DATE_FORMAT(job.datetime_served, '%m/%d/%Y') as datetime_served, concat(server.namefirst,' ', server.namelast) as server_name FROM job
LEFT JOIN kase ON job.kase_id = kase.id
LEFT JOIN kasebilling ON kasebilling.kase_id = kase.id
LEFT JOIN server ON job.server_id = server.id
left join client on client.id=kase.client_id
left join LUcourt on LUcourt.id=kase.court_id WHERE job.subscriber_id = 1 and job_id in (select distinct job.id from job where job.subscriber_id = '1' order by id+0) LIMIT 0,500