我有两张这样的桌子.'order'表有21886行.
CREATE TABLE `order` (
`id` bigint(20) unsigned NOT NULL,
`reg_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_reg_date` (`reg_date`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
CREATE TABLE `order_detail_products` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`order_id` bigint(20) unsigned NOT NULL,
`order_detail_id` int(11) NOT NULL,
`prod_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `idx_order_detail_id` (`order_detail_id`,`prod_id`),
KEY `idx_order_id` (`order_id`,`order_detail_id`,`prod_id`)
) ENGINE=InnoDB AUTO_INCREMENT=572375 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Run Code Online (Sandbox Code Playgroud)
我的问题在这里.
MariaDB [test]> explain
-> SELECT DISTINCT A.id
-> FROM order A
-> JOIN order_detail_products …Run Code Online (Sandbox Code Playgroud) 我想知道Using index condition和之间的区别Using where; Using index.我认为两种方法都使用索引来获取第一个结果记录集,并使用WHERE条件进行过滤.
Q1.有什么不同?
Q2.哪个更好?
谢谢.
ClassCastException随机发生以恢复onRestoreInstanceState()中的Vector.通常,恢复向量很好,但有时会发生异常.
我认为它发生在活动进入后台并被破坏但我不确定.
有任何想法吗?谢谢.
Stack<LocationInfo> mLocationInfoVector;
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putSerializable("locationInfos", mLocationInfoVector);
super.onSaveInstanceState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
if (savedInstanceState.getSerializable("locationInfos") != null) {
@SuppressWarnings("unchecked")
mLocationInfoVector= (Stack<LocationInfo>) savedInstanceState.getSerializable("locationInfos");
}
super.onRestoreInstanceState(savedInstanceState);
}
Run Code Online (Sandbox Code Playgroud)
添加:
我忘了附上异常日志.那是
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Stack
Run Code Online (Sandbox Code Playgroud) 我在header.h中定义了变量'a',并在test1.cpp,test2.cpp中使用它.当我构建它时,我得到一个链接错误,如
致命错误LNK1169:找到一个或多个多重定义的符号
有什么问题?我想使用全局变量'a'可以在多个cpp中使用.
header.h
int a = 0;
Run Code Online (Sandbox Code Playgroud)
main.cpp中
#include "header.h"
#include "test1.h"
#include "test2.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
test1(); // expected output : 0
test1(); // expected output : 1
test2(); // expected output : 2
test2(); // expected output : 3
cout << "in main : " << a << endl; // expected output : 3
return 0;
}
Run Code Online (Sandbox Code Playgroud)
test1.h
extern int a;
void test1();
Run Code Online (Sandbox Code Playgroud)
test1.cpp
#include …Run Code Online (Sandbox Code Playgroud) mysql ×2
android ×1
bundle ×1
c++ ×1
distinct ×1
group-by ×1
indexing ×1
performance ×1
serializable ×1