MySQL查询执行速度非常慢

时间:2013-11-21 15:40:15

标签: mysql bash ubuntu

我在Ubuntu上用MySQL创建了一个数据库,以便了解我拥有的漫画,并获得一些问题,例如问题的标题,它的作者,编辑,铅笔等。查询本身没有问题但是数量有问题执行它所需的时间。

这是查询:

select 
  issue.issueNR, 
  issue.issueName, 
  series.seriesName, 
  writer.writerName, 
  editor.editorName, 
  penciler.pencilerName, 
  letterer.lettererName, 
  colourist.colouristName,
  coverArtist.coverArtistName
from 
  writer, writerLookup, 
  editor, editorLookup, 
  penciler, pencilerLookup, 
  letterer, lettererLookup, 
  colourist, colouristLookup,
  coverArtist, coverArtistLookup,
  issue, 
  series 
where 
  (issue.issueID = writerLookup.issueID and writerLookup.writerID = writer.writerID) 
  and (issue.issueID = editorLookup.issueID and editorLookup.editorID = editor.editorID) 
  and (issue.issueID = pencilerLookup.issueID and pencilerLookup.pencilerID = penciler.pencilerID)
  and (issue.issueID = lettererLookup.issueID and lettererLookup.lettererID = letterer.lettererID)
  and (issue.issueID = colouristLookup.issueID and colouristLookup.colouristID = colourist.colouristID)
  and (issue.issueID = coverArtistLookup.issueID and coverArtistLookup.coverArtistID = coverArtist.coverArtistID)  
  and issue.seriesID = series.seriesID;

结果:

+---------+---------------------------+---------------------------+-------------+-------------+----------------+-------------------+---------------+-----------------+
| issueNR | issueName                 | seriesName                | writerName  | editorName  | pencilerName   | lettererName      | colouristName | coverArtistName |
+---------+---------------------------+---------------------------+-------------+-------------+----------------+-------------------+---------------+-----------------+
|       1 | X-Men                     | X-Men                     | Stan Lee    | Stan Lee    | Jack Kirby     | Sam Rosen         | Uncredited    | Jack Kirby      |
|       1 | X-Men                     | X-Men                     | Stan Lee    | Stan Lee    | Jack Kirby     | Sam Rosen         | Uncredited    | Sol Brodsky     |
|       1 | The Long Way Home, Part 1 | Buffy, the Vampire Slayer | Joss Whedon | Scott Allie | Georges Jeanty | Richard Starkings | Dave Stewart  | Jo Chen         |
|       1 | The Long Way Home, Part 1 | Buffy, the Vampire Slayer | Joss Whedon | Scott Allie | Georges Jeanty | Jimmy Betancourt  | Dave Stewart  | Jo Chen         |
|       1 | The Long Way Home, Part 1 | Buffy, the Vampire Slayer | Joss Whedon | Scott Allie | Georges Jeanty | Richard Starkings | Dave Stewart  | Georges Jeanty  |
|       1 | The Long Way Home, Part 1 | Buffy, the Vampire Slayer | Joss Whedon | Scott Allie | Georges Jeanty | Jimmy Betancourt  | Dave Stewart  | Georges Jeanty  |
+---------+---------------------------+---------------------------+-------------+-------------+----------------+-------------------+---------------+-----------------+
6 rows in set (2 min 55.66 sec)

正如你所看到的那样,生成6行需要将近3分钟,这实在太慢了,特别是因为这不是完整的查询,因为我还有一个墨水,tpb,......

您可以在此处找到我用来创建表格的bash脚本:http://textuploader.com/degt

是否有某种方法可以使查询或我的数据库更高效?

0 个答案:

没有答案