DECLARE @StartTime datetime,@EndTime datetime SELECT @StartTime=GETDATE() select distinct born_on.name from born_on,died_on where (FLOOR(('2012-01-30'-born_on.DOB)/365.25) <= ( select max(FLOOR((died_on.DOD - born_on.DOB)/365.25)) from died_on,born_on where (died_on.name=born_on.name)) ) and (born_on.name <> All(select name from died_on)) SELECT @EndTime=GETDATE() SELECT DATEDIFF(ms,@StartTime,@EndTime) AS [Duration in millisecs]
sql:/home/an/Desktop/dbms/query.sql:9: ERROR: Syntax error at or near "@" LINE 1: DECLARE @StartTime datetime,@EndTime datetime
为了测试目的,您也可以使用
原文链接:https://www.f2er.com/postgresql/192589.htmlEXPLAIN ANALYZE
.
EXPLAIN ANALYZE SELECT DISTINCT born_on.name FROM born_on b WHERE floor(('2012-01-30'::date - b.dob) / 365.25) <= ( SELECT floor((max(d1.dod - b1.dob)/365.25)) FROM born_on b1 JOIN died_on d1 USING (name) ) AND NOT EXISTS ( SELECT * FROM died_on d2 WHERE d2.name = b.name );
显示查询计划以外的总运行时间.执行几次以排除工件.
A couple of options有更多的细节.