![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||||
| |||||
|
|
Deployment is on a slightly older version than I have on my development machine Server version: 5.0.51a-24+lenny5 vs. Server version: 5.1.41-3ubuntu12.10 |
|
In the earlier MySQL version, the indices look like this: Keyname Type Field Cardinality ----------------------------------------------------- idx_kursnr_kursliste INDEX kurs_nr 1590 idx_abt_kursliste INDEX abteilung 125 idx_kursname_kursliste INDEX kurs_name 265 idx_dow_zeit INDEX dow 119 --- lektion idx_kuerzel INDEX lp_kuerzel 367 And on my development machine: Keyname Type Unique Packed Field Cardinality --------------------------------------------------------------------- idx_kursnr_kursliste BTREE No No kurs_nr 796 idx_abt_kursliste BTREE No No abteilung 129 idx_kursname_kursliste BTREE No No kurs_name 207 idx_dow_zeit BTREE No No dow 6 --- lektion 119 idx_kuerzel BTREE No No lp_kuerzel 298 Notice the difference in cardinality. |
|
Is it possible that the different index data can cause the queries to actually miss some data? |
|
If necessary, I can post the SQL of the views, but it is quite large. |
|
Has anyone else encountered this problem when upgrading MySQL from 5.0 to 5.1? |
#3
| |||
| |||
|
|
How is this possible? Deployment is on a slightly older version than I have on my development machine, but since I am not doing anything exotic it really shouldn't matter: Deployment: ======================== Server version: 5.0.51a-24+lenny5 MySQL client version: 5.0.51a Development: ======================== Server version: 5.1.41-3ubuntu12.10 MySQL client version: 5.1.41 Fortunately, it seems that the queries and views running in the deployment environment are returning the correct data, but on my development machine it is not. It isn't a PHP or charset problem either because I can see the data discrepancies when I run the SELECT statements in the terminal. I know the data is the same because I started over with a clean database (no tables, routines or views) and recreated everything from a dump I made from the development machine. The only real difference I noticed is in some indices on one relatively substantial table (abt. 5000 rows) which drives the query in question. Here is the table structure: CREATE TABLE `kursliste` ( `kurs_nr` int(11) NOT NULL, `abteilung` varchar(50) collate utf8_unicode_ci default NULL, `lp_kuerzel` varchar(50) collate utf8_unicode_ci default NULL, `kurs_name` varchar(50) collate utf8_unicode_ci default NULL, `zimmer` varchar(50) collate utf8_unicode_ci default NULL, `dow` int(11) NOT NULL, `lektion` int(11) NOT NULL, `semester` int(11) NOT NULL default '3' COMMENT '1 = nur 1. Semester; 2 = nur 2. Semester; 3 = ganzjährig', KEY `idx_kursnr_kursliste` (`kurs_nr`), KEY `idx_abt_kursliste` (`abteilung`), KEY `idx_kursname_kursliste` (`kurs_name`), KEY `idx_dow_zeit` (`dow`,`lektion`), KEY `idx_kuerzel` (`lp_kuerzel`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; In the earlier MySQL version, the indices look like this: ----------------------------------------------------- Keyname Type Field Cardinality ----------------------------------------------------- idx_kursnr_kursliste INDEX kurs_nr 1590 idx_abt_kursliste INDEX abteilung 125 idx_kursname_kursliste INDEX kurs_name 265 idx_dow_zeit INDEX dow 119 --- lektion idx_kuerzel INDEX lp_kuerzel 367 ----------------------------------------------------- And on my development machine: --------------------------------------------------------------------- Keyname Type Unique Packed Field Cardinality --------------------------------------------------------------------- idx_kursnr_kursliste BTREE No No kurs_nr 796 idx_abt_kursliste BTREE No No abteilung 129 idx_kursname_kursliste BTREE No No kurs_name 207 idx_dow_zeit BTREE No No dow 6 --- lektion 119 idx_kuerzel BTREE No No lp_kuerzel 298 --------------------------------------------------------------------- Notice the difference in cardinality. Is it possible that the different index data can cause the queries to actually miss some data? If necessary, I can post the SQL of the views, but it is quite large. Has anyone else encountered this problem when upgrading MySQL from 5.0 to 5.1? |
#4
| ||||
| ||||
|
|
Robert Hairgrove<nobody (AT) hogwash (DOT) com> wrote: If necessary, I can post the SQL of the views, but it is quite large. The data in the base table(s) and the view definition is really the same? How did you check that? |
|
What are the differences you are seeing? Different number of rows? Different row content? Big difference or small? EXPLAIN results? |
|
And since views are involved: what about the query that defines the view? Same result? And same as SELECT * from the view? |
|
Has anyone else encountered this problem when upgrading MySQL from 5.0 to 5.1? Have you read the manual? The "Upgrade from 5.0 to 5.1" section? Noticed the "incompatible change"s? |
#5
| |||
| |||
|
|
On 08/08/2011 11:16 AM, Axel Schwenke wrote: What are the differences you are seeing? Different number of rows? Different row content? Big difference or small? EXPLAIN results? Different number of rows (92 vs. 96 for one test case). EXPLAIN results are almost exactly the same. |
|
The query for the view I was executing has three UNION select statements; the first two selects are SELECT DISTINCT, the third only a regular SELECT statement. As it turns out, the results are distinct anyway (at least for my few test cases), but then using DISTINCT shouldn't make any difference in the results returned, should it? However, the same query with the same underlying data running on MySQL 5.0 returns 96 rows, and running on MySQL 5.1 only 92 rows. |
|
When I remove the DISTINCT keyword, both queries return the same (correct) data: 96 rows. Now I have to test a lot of things to make sure that I don't actually need DISTINCT. Perhaps SELECT DISTINCT behaves differently when used together with unions? |
![]() |
| Thread Tools | |
| Display Modes | |
| |