Unix Technical Forum

MS Access query in MySQL

This is a discussion on MS Access query in MySQL within the MySQL forums, part of the Database Server Software category; --> Hi all, I have just migrated all of my data from an MS Access database to MySQL using Navicat. ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 09:47 AM
Peter
 
Posts: n/a
Default MS Access query in MySQL

Hi all,

I have just migrated all of my data from an MS Access database to
MySQL using Navicat.

There is a query in MS Access that I use to find duplicate words in my
table. The SQL generated by MS Access is:

SELECT vocab.English, vocab.POS, vocab.Kana, vocab.Kanji, vocab.jlpt,
vocab.cardNum, vocab.dEntered
FROM vocab
WHERE (((vocab.Kana) In (SELECT kana FROM vocab As Tmp GROUP BY kana
HAVING Count(*)>1 )))
ORDER BY vocab.Kana;

When I put this same query into MySQL the CPU usage goes up to 100%
and takes forever to complete (actually I haven't waited forever but
it takes a long time and then I quit the query).

Can someone tell me why this happens and what would be an equivalent
query to use in MySQL?

I am using MySQL server version: 5.0.27-community-nt.

Many thanks,

Peter.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 09:47 AM
nk
 
Posts: n/a
Default Re: MS Access query in MySQL

On May 10, 1:43 pm, Peter <petethegai...@gmail.com> wrote:
> Hi all,
>
> I have just migrated all of my data from an MS Access database to
> MySQL using Navicat.
>
> There is a query in MS Access that I use to find duplicate words in my
> table. The SQL generated by MS Access is:
>
> SELECT vocab.English, vocab.POS, vocab.Kana, vocab.Kanji, vocab.jlpt,
> vocab.cardNum, vocab.dEntered
> FROM vocab
> WHERE (((vocab.Kana) In (SELECT kana FROM vocab As Tmp GROUP BY kana
> HAVING Count(*)>1 )))
> ORDER BY vocab.Kana;

Do you have an index on vocab.kana? Otherwise, depending on the size
of your database, MySQL might have to sort through a lot of rows,
which could explain the high CPU usage.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 09:47 AM
Captain Paralytic
 
Posts: n/a
Default Re: MS Access query in MySQL

On 10 May, 12:43, Peter <petethegai...@gmail.com> wrote:
> Hi all,
>
> I have just migrated all of my data from an MS Access database to
> MySQL using Navicat.
>
> There is a query in MS Access that I use to find duplicate words in my
> table. The SQL generated by MS Access is:
>
> SELECT vocab.English, vocab.POS, vocab.Kana, vocab.Kanji, vocab.jlpt,
> vocab.cardNum, vocab.dEntered
> FROM vocab
> WHERE (((vocab.Kana) In (SELECT kana FROM vocab As Tmp GROUP BY kana
> HAVING Count(*)>1 )))
> ORDER BY vocab.Kana;
>
> When I put this same query into MySQL the CPU usage goes up to 100%
> and takes forever to complete (actually I haven't waited forever but
> it takes a long time and then I quit the query).
>
> Can someone tell me why this happens and what would be an equivalent
> query to use in MySQL?
>
> I am using MySQL server version: 5.0.27-community-nt.
>
> Many thanks,
>
> Peter.


Regardless of what nk says, I would convert this to a self join query.
Untested:
SELECT
vocab.English,
vocab.POS,
vocab.Kana,
vocab.Kanji,
vocab.jlpt,
vocab.cardNum,
vocab.dEntered
FROM vocab v1
JOIN vocab v2 USING(Kana)
HAVING Count(*)>1
ORDER BY v1.Kana;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 09:47 AM
Peter
 
Posts: n/a
Default Re: MS Access query in MySQL

On May 10, 10:04 pm, nk <nkoell...@gmail.com> wrote:
> On May 10, 1:43 pm, Peter <petethegai...@gmail.com> wrote:> Hi all,
>
> > I have just migrated all of my data from an MS Access database to
> > MySQL using Navicat.

>
> > There is a query in MS Access that I use to find duplicate words in my
> > table. The SQL generated by MS Access is:

>
> > SELECT vocab.English, vocab.POS, vocab.Kana, vocab.Kanji, vocab.jlpt,
> > vocab.cardNum, vocab.dEntered
> > FROM vocab
> > WHERE (((vocab.Kana) In (SELECT kana FROM vocab As Tmp GROUP BY kana
> > HAVING Count(*)>1 )))
> > ORDER BY vocab.Kana;

>
> Do you have an index on vocab.kana? Otherwise, depending on the size
> of your database, MySQL might have to sort through a lot of rows,
> which could explain the high CPU usage.


Yeah Navicat created three indexes on this table when I imported the
data.
Should these indexes be a special type? I have the options in Navicat
of "Normal", "Unique" & "Full Text" However when I try to change them
to "Full Text" it says the table type doesn't support this kind of
index.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:55 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com