SQLite查询挂在连接上

时间:2013-11-01 16:34:33

标签: sql sqlite

我有一个包含2个表,调查和同步器的数据库。 Survey具有SurveyId(Guid)的主键,这是syncheader表中的外键。

我遇到的问题是,当我在这些表之间连接时,sqlite查询将挂起并且不返回任何响应(在Firefox sqlite manager和SQLite2009Pro中),我的代码在尝试运行查询时将返回错误,即使它是有效的语法:

CREATE TABLE "syncheader" (
    syncheaderid guid not null constraint pkc_syncheader_syncheaderid primary key,
    surveyid guid not null,
    surveydate datetime null,
    syncsurveyorid guid null,
    isdirty boolean null,
    assetid int null,
    syncinspectionid int null,
    inspectionid int null
);
CREATE TABLE survey (
    surveyid guid not null constraint pkc_survey_surveyid primary key,
    assetid int not null,
    sectionid int not null,
    surveydate datetime null,
    syncsurveyorid guid null,
    isdirty boolean null,
    inspectionid int null,
    status int default 0 null
);

SELECT sh.surveyid SurveyID, sh.syncheaderid AS SyncHeaderID, 
sh.surveydate AS SurveyDate, sh.syncsurveyorid AS SyncSurveyorID, 
sh.assetid AS AssetID, sh.inspectionid AS InspectionID, 
sh.syncinspectionid AS SyncInspectionID 
FROM syncheader sh JOIN survey s ON sh.surveyid = s.surveyid 
WHERE sh.isdirty = 1 
AND s.isdirty = 1 
ORDER BY sh.surveydate LIMIT 0, 100

EXPLAIN QUERY PLAN输出:

0 0 0 SCAN TABLE syncheader1 AS sh (~168 rows)
0 1 1 SEARCH TABLE survey AS s USING INDEX sqlite_autoindex_survey_1 (surveyid=?) (~1 rows)
0 0 0 USE TEMP B-TREE FOR ORDER BY

0 个答案:

没有答案