@符号在此sql表达式中表示什么?
update some_table set some_number=(@some_number+1) where some_id=1;
它似乎返回与以下相同的结果:
update some_table set some_number=some_number+1 where some_id=1;
@符号在此sql表达式中表示什么?
update some_table set some_number=(@some_number+1) where some_id=1;
它似乎返回与以下相同的结果:
update some_table set some_number=some_number+1 where some_id=1;
据我了解,主键在定义上是唯一的。如果这是真的,有人会想要在主键上选择 DISTINCT 吗?这是否实用/有用?
这个查询
SELECT *
FROM
( SELECT event_id
FROM events_201806
WHERE registry_name='$VCZN://externalcenter/ninaExtCenter_ZN'
UNION ALL SELECT event_id
FROM events_201805
WHERE registry_name='$VCZN://externalcenter/ninaExtCenter_ZN'
UNION ALL SELECT event_id
FROM events_201804
WHERE registry_name='$VCZN://externalcenter/ninaExtCenter_ZN'
UNION ALL SELECT event_id
FROM events_201803
WHERE registry_name='$VCZN://externalcenter/ninaExtCenter_ZN') AS ids
NATURAL INNER JOIN events;
返回 456 个结果,耗时约 20 毫秒。
添加 ORDER BY
SELECT *
FROM
(SELECT event_id
FROM events_201806
WHERE registry_name='$VCZN://externalcenter/ninaExtCenter_ZN'
UNION ALL SELECT event_id
FROM events_201805
WHERE registry_name='$VCZN://externalcenter/ninaExtCenter_ZN'
UNION ALL SELECT event_id
FROM events_201804
WHERE registry_name='$VCZN://externalcenter/ninaExtCenter_ZN'
UNION ALL SELECT event_id
FROM events_201803
WHERE registry_name='$VCZN://externalcenter/ninaExtCenter_ZN') AS ids
NATURAL INNER JOIN events
ORDER BY event_ts DESC;
导致查询需要很长时间才能完成,大约 10 分钟。
关于如何解决这个问题的任何指示?