Home » Performance » MySQL » Query uses long time
icon5.gif  Query uses long time [message #1568] Wed, 01 August 2007 08:58 Go to next message
ZeroG  is currently offline ZeroG
Messages: 2
Registered: August 2007
Location: Austra
Junior Member
Hey NG

So, I am new here in the forum, so the first, I wan't to say is: Hallo to everyone.

So, I use MySQL v4.1.16 server.
I have two tables

-- Table: invnrbeschreibung

-- DROP TABLE `invnrbeschreibung`;

CREATE TABLE `invnrbeschreibung` (
ID bigint AUTO_INCREMENT NOT NULL,
`InvNr` char(2) NOT NULL DEFAULT '0',
`Beschreibung` varchar(100) NOT NULL,
/* Keys */
PRIMARY KEY (ID)
) ENGINE = MyISAM;

CREATE FULLTEXT INDEX `fulltext`
ON `invnrbeschreibung`
(`InvNr`, `Beschreibung`);

CREATE INDEX `index`
ON `invnrbeschreibung`
(`Beschreibung`);

------------------------------------------------------------ ----
-- Table: artikelstamm

-- DROP TABLE `artikelstamm`;

CREATE TABLE `artikelstamm` (
ID bigint AUTO_INCREMENT NOT NULL,
`InvNr` char(2) NOT NULL,
`Lieferant` int(2) UNSIGNED ZEROFILL NOT NULL DEFAULT '00',
`ArtikelNr` varchar(6) NOT NULL,
`Groesse` varchar(4) NOT NULL,
`Farbe` varchar(5) NOT NULL,
`ArtBez` varchar(30) NOT NULL,
`Mwst` int(10) NOT NULL DEFAULT '20',
`VPreis` int(10) NOT NULL DEFAULT '0',
`Lagermenge` int NOT NULL DEFAULT '0',
`MengeVK` int NOT NULL DEFAULT '0',
`WertVK` int(10) NOT NULL DEFAULT '0',
`AnzVK` int NOT NULL DEFAULT '0',
`DivArt` char NOT NULL DEFAULT '0',
`Warnung` int NOT NULL DEFAULT '0',
`iCode` double(6,0) UNSIGNED ZEROFILL NOT NULL DEFAULT '000000',
`oCode` double(20,0) NOT NULL DEFAULT '0',
`EPreis` int(10) NOT NULL DEFAULT '0',
`Lagwert` int(10) NOT NULL DEFAULT '0',
`InvMenge` int NOT NULL DEFAULT '0',
`InvWert` int(10) NOT NULL DEFAULT '0',
`DatlZug` date NOT NULL DEFAULT '1900-12-31',
`DatlVK` date NOT NULL DEFAULT '1900-12-31',
`DatlInv` date NOT NULL DEFAULT '1900-12-31',
`DatSeit` date NOT NULL DEFAULT '1900-12-31',
`DatlAenderung` date NOT NULL DEFAULT '1900-12-31',
/* Keys */
PRIMARY KEY (ID)
) ENGINE = MyISAM;

CREATE INDEX `Einmalig`
ON `artikelstamm`
(`iCode`);

CREATE INDEX `Indiziert`
ON `artikelstamm`
(`Lieferant`);

CREATE FULLTEXT INDEX `indiziertfulltext`
ON `artikelstamm`
(`InvNr`);
------------------------------------------------------------ ----
So, I have the following SQL Statement to get the Names from the Invnrbeschreibung fitting to the artikelstamm InvNr

SELECT DISTINCT artikelstamm.InvNr as InvNr, InvNrBeschreibung.Beschreibung as Beschreibung FROM voptneu.artikelstamm RIGHT OUTER JOIN voptneu.InvNrBeschreibung ON voptneu.artikelstamm.InvNr = voptneu.InvNrBeschreibung.InvNr ORDER BY InvNr

So, the table artikelstamm contains about 40000 entries & the table invnrbeschreibung contains about 30 entries

The query uses up to 12 seconds.... - Is there any kind of performance tuning you could tell me?

THX
Re: Query uses long time [message #1600 is a reply to message #1568 ] Thu, 16 August 2007 08:43 Go to previous messageGo to next message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
Please always post EXPLAIN for query you're trying to get help with.


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Re: Query uses long time [message #1604 is a reply to message #1568 ] Thu, 16 August 2007 08:59 Go to previous message
ZeroG  is currently offline ZeroG
Messages: 2
Registered: August 2007
Location: Austra
Junior Member
Hey
Thanks for reply

I've attached a JPEG, what Explain shows to me.

THX

  • Attachment: Explain.jpg
    (Size: 16.75KB, Downloaded 132 time(s))

Previous Topic:Help.. How to communicate MySQL with RFID
Next Topic:Performance Optimizing INNODB
Goto Forum:
  


Current Time: Fri Jul 10 03:44:31 EDT 2009

Total time taken to generate the page: 0.01293 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.