Some records show up on multiple result "pages" with the following query:
SELECT
`description`,
`wallpaper`
FROM
`bbr_bar`
WHERE
`country_id` = '2510769'
ORDER BY
`online` DESC
For instance, record with id 99 shows up on the first "page" (LIMIT 10 OFFSET 0
) but also on the last one LIMIT 10 OFFSET 50
. Obviously this should not happen.
The problem disappears under the the following circumstances:
- if I don't filter the query, or don't order it (both
country_id
andonline
areint(11)
, not foreign keys) - if I remove one of the two fields from the
SELECT
clause (bothvarchar(255)
, not foreign keys) - if I delete some tables or fields in the schema. However, afters hours of effort, I am still unable to say for sure which tables/fields have an impact and which ones don't. Looks like random (even if I know it is not). Hence I don't paste here any
CREATE TABLE
orINSERT
statement as I don't think they are relevant.
Only thing I can say for sure is that if I mysqldump
all tables and restore them in a new schema, the problem is still there.
(There are other fields in the table but adding/removing them has no effect on the result).
Questions:
- Am I right if I conclude that something is corrupted in my schema?
- How could I fix this?
(MySQL version: 5.6.24 Win32 x86)
Best Answer
I have some bad news for you: According to MySQL, IT'S NOT A BUG !!!
There are two bug reports on this behavior and is considered non-critical
Here is the rationale expressed in Bug #69732
In your particular case, the
online
field is probably not distinct enough. Even if you indexbbr_bar
by (country_id
,online
), this may still be not distinct enough. You may have to involve another column to drive the sort order (perhaps an auto increment field or a timestamp field).Give it a try!!!!