Quantcast
Channel: MySQL Forums - NDB clusters
Viewing all articles
Browse latest Browse all 1560

Bug in select for ndbcluster? (no replies)

$
0
0
I'm fairly new to MySQL clustering. Can someone explain to me why this is happening? I'm not sure if it's a bug, or if there's something I don't quite understand about using clustering.

This is the original query from our admin search page, which works fine.

SELECT *
FROM nuke_users
WHERE name LIKE '%@freeinternet%'
OR username LIKE '%@freeinternet%'
OR user_email LIKE '%@freeinternet%'
OR user_id = '@freeinternet'
ORDER BY username
LIMIT 100;

I was trying to run some queries directly, and I simplified it to this to just check user_email, and it doesn't work.

I've modified the query slightly for posting here with results.

mysql> SELECT user_id, user_email
-> FROM nuke_users
-> WHERE user_email LIKE '%@freeinternet%'
-> OR user_id = '%@freeinternet%';
+---------+------------------------------+
| user_id | user_email |
+---------+------------------------------+
| 2 | editor@freeinternetpress.com |
+---------+------------------------------+
1 row in set, 1 warning (0.03 sec)


If I remove the user_id clause, it returns nothing.

mysql> SELECT user_id, user_email
-> FROM nuke_users
-> WHERE user_email LIKE '%@freeinternet%';
Empty set (0.01 sec)

Obviously, the column that matches is the user_email column, so the user_id column is irrelevent to the query. It's just a number, and will only match if I happen to search for the user_id.

Here's the explains for both queries.

mysql> EXPLAIN SELECT user_id, user_email
-> FROM nuke_users
-> WHERE user_email LIKE '%@freeinternet%'
-> OR user_id = '%@freeinternet%';
+----+-------------+------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | nuke_users | ALL | PRIMARY,uid | NULL | NULL | NULL | 5439 | Using where |
+----+-------------+------------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.01 sec)



mysql> EXPLAIN SELECT user_id, user_email
-> FROM nuke_users
-> WHERE user_email LIKE '%@freeinternet%';
+----+-------------+------------+------+---------------+------+---------+------+------+-----------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------+------+---------------+------+---------+------+------+-----------------------------------+
| 1 | SIMPLE | nuke_users | ALL | NULL | NULL | NULL | NULL | 5439 | Using where with pushed condition |
+----+-------------+------------+------+---------------+------+---------+------+------+-----------------------------------+
1 row in set (0.00 sec)


And the ndb_mgm status.

Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=11 @172.16.1.10 (mysql-5.5.19 ndb-7.2.4, Nodegroup: 0)
id=12 @172.16.1.11 (mysql-5.5.19 ndb-7.2.4, Nodegroup: 0, Master)

[ndb_mgmd(MGM)] 2 node(s)
id=1 @172.16.1.10 (mysql-5.5.19 ndb-7.2.4)
id=2 @172.16.1.11 (mysql-5.5.19 ndb-7.2.4)

[mysqld(API)] 2 node(s)
id=51 @172.16.1.10 (mysql-5.5.19 ndb-7.2.4)
id=52 @172.16.1.11 (mysql-5.5.19 ndb-7.2.4)

I get the same result using either node. And no, the nodes are not on the web server.



This is the table create:

CREATE TABLE `nuke_users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(60) NOT NULL DEFAULT '',
`username` varchar(25) NOT NULL DEFAULT '',
`user_email` varchar(255) NOT NULL DEFAULT '',
`user_website` varchar(255) NOT NULL DEFAULT '',
`user_avatar` varchar(255) NOT NULL DEFAULT '',
`user_regdate` varchar(20) NOT NULL DEFAULT '',
`user_regip` varchar(16) NOT NULL DEFAULT '',
`user_reghost` varchar(255) NOT NULL DEFAULT '',
`user_password` varchar(40) NOT NULL DEFAULT '',
`user_password_plain` varchar(255) NOT NULL DEFAULT '',
`regkey` varchar(255) NOT NULL DEFAULT '',
`counter` int(11) NOT NULL DEFAULT '0',
`newsletter` int(1) NOT NULL DEFAULT '1',
`user_level` int(10) NOT NULL DEFAULT '1',
`user_active` tinyint(1) DEFAULT '1',
`paypalstatus` varchar(20) NOT NULL DEFAULT 'new signup',
`donation_expire` varchar(24) NOT NULL DEFAULT '',
`donation_ttl` decimal(16,2) NOT NULL DEFAULT '0.00',
`donation_last` varchar(24) NOT NULL DEFAULT '',
PRIMARY KEY (`user_id`),
KEY `uname` (`username`),
KEY `active_newsletter` (`user_active`,`newsletter`),
KEY `uid` (`user_id`),
KEY `uname_upass` (`username`,`user_password`),
KEY `regkey` (`regkey`)
) ENGINE=ndbcluster AUTO_INCREMENT=16071 DEFAULT CHARSET=utf8

I should mention, this is not PHPNuke. It was a long time ago, but I rewrote the whole site from scratch, and used some of the tables from the old site. I never bothered to change the table names.

Viewing all articles
Browse latest Browse all 1560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>