⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subqueryflattening.out

📁 derby database source code.good for you.
💻 OUT
📖 第 1 页 / 共 5 页
字号:
ij> -- test subquery flattening into outer query blockset isolation to rr;0 rows inserted/updated/deletedij> -- tests for flattening a subquery based on a-- uniqueness condition-- by default, holdability of ResultSet objects created using this Connection object is true. Following will set it to false for this connection.NoHoldForConnection;ij> -- create some tablescreate table outer1 (c1 int, c2 int, c3 int);0 rows inserted/updated/deletedij> create table outer2 (c1 int, c2 int, c3 int);0 rows inserted/updated/deletedij> create table noidx (c1 int);0 rows inserted/updated/deletedij> create table idx1 (c1 int);0 rows inserted/updated/deletedij> create unique index idx1_1 on idx1(c1);0 rows inserted/updated/deletedij> create table idx2 (c1 int, c2 int);0 rows inserted/updated/deletedij> create unique index idx2_1 on idx2(c1, c2);0 rows inserted/updated/deletedij> create table nonunique_idx1 (c1 int);0 rows inserted/updated/deletedij> create index nonunique_idx1_1 on nonunique_idx1(c1);0 rows inserted/updated/deletedij> insert into outer1 values (1, 2, 3);1 row inserted/updated/deletedij> insert into outer1 values (4, 5, 6);1 row inserted/updated/deletedij> insert into outer2 values (1, 2, 3);1 row inserted/updated/deletedij> insert into outer2 values (4, 5, 6);1 row inserted/updated/deletedij> insert into noidx values 1, 1;2 rows inserted/updated/deletedij> insert into idx1 values 1, 2;2 rows inserted/updated/deletedij> insert into idx2 values (1, 1), (1, 2);2 rows inserted/updated/deletedij> insert into nonunique_idx1 values 1, 1;2 rows inserted/updated/deletedij> -- cases where subqueries don't get flattened-- (we would get incorrect results with -- incorrect flattening)-- one of tables in subquery doesn't have indexselect * from outer1 where c1 in (select idx1.c1 from noidx, idx1 where idx1.c1 = noidx.c1);C1         |C2         |C3         -----------------------------------1          |2          |3          ij> -- group by in subqueryselect * from outer1 o where c1 <= (select c1 from idx1 i group by c1);C1         |C2         |C3         -----------------------------------ERROR 21000: Scalar subquery is only allowed to return a single row.ij> -- otherwise flattenable subquery under an or -- subquery returns no rowsselect * from outer1 o where c1 + 0 = 1 or c1 in (select c1 from idx1 i where i.c1 = 0);C1         |C2         |C3         -----------------------------------1          |2          |3          ij> select * from outer1 o where c1 in (select c1 from idx1 i where i.c1 = 0) or c1 + 0 = 1;C1         |C2         |C3         -----------------------------------1          |2          |3          ij> -- empty subquery in select list which is otherwise flattenableselect (select c1 from idx1 where c1 = 0) from outer1;1          -----------NULL       NULL       ij> -- multiple tables in subquery-- no one table's equality condition based-- solely on constants and correlation columnsselect * from outer1 o where exists (select * from idx2 i, idx1 where o.c1 = i.c1 and i.c2 = idx1.c1);C1         |C2         |C3         -----------------------------------1          |2          |3          ij> -- subqueries that should get flattenedcall SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1);0 rows inserted/updated/deletedij> maximumdisplaywidth 40000;ij> -- simple INselect * from outer1 o where o.c1 in (select c1 from idx1);C1         |C2         |C3         -----------------------------------1          |2          |3          ij> values SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS();1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Statement Name: 	nullStatement Text: 	-- simple INselect * from outer1 o where o.c1 in (select c1 from idx1)Parse Time: 0Bind Time: 0Optimize Time: 0Generate Time: 0Compile Time: 0Execute Time: 0Begin Compilation Timestamp : nullEnd Compilation Timestamp : nullBegin Execution Timestamp : nullEnd Execution Timestamp : nullStatement Execution Plan Text: Project-Restrict ResultSet (4):Number of opens = 1Rows seen = 1Rows filtered = 0restriction = falseprojection = true	constructor time (milliseconds) = 0	open time (milliseconds) = 0	next time (milliseconds) = 0	close time (milliseconds) = 0	restriction time (milliseconds) = 0	projection time (milliseconds) = 0Source result set:	Nested Loop Exists Join ResultSet:	Number of opens = 1	Rows seen from the left = 2	Rows seen from the right = 1	Rows filtered = 0	Rows returned = 1		constructor time (milliseconds) = 0		open time (milliseconds) = 0		next time (milliseconds) = 0		close time (milliseconds) = 0	Left result set:		Table Scan ResultSet for OUTER1 at serializable isolation level using share table locking chosen by the optimizer		Number of opens = 1		Rows seen = 2		Rows filtered = 0		Fetch Size = 16			constructor time (milliseconds) = 0			open time (milliseconds) = 0			next time (milliseconds) = 0			close time (milliseconds) = 0			next time in milliseconds/row = 0		scan information: 			Bit set of columns fetched=All			Number of columns fetched=3			Number of pages visited=1			Number of rows qualified=2			Number of rows visited=2			Scan type=heap			start position: null			stop position: null			qualifiers:None	Right result set:		Index Scan ResultSet for IDX1 using index IDX1_1 at serializable isolation level using share row locking chosen by the optimizer		Number of opens = 2		Rows seen = 1		Rows filtered = 0		Fetch Size = 1			constructor time (milliseconds) = 0			open time (milliseconds) = 0			next time (milliseconds) = 0			close time (milliseconds) = 0			next time in milliseconds/row = 0		scan information: 			Bit set of columns fetched={0}			Number of columns fetched=1			Number of deleted rows visited=0			Number of pages visited=2			Number of rows qualified=1			Number of rows visited=1			Scan type=btree			Tree height=1			start position: 	>= on first 1 column(s).	Ordered null semantics on the following columns: 			stop position: 	> on first 1 column(s).	Ordered null semantics on the following columns: 			qualifiers:Noneij> -- simple EXISTSselect * from outer1 o where exists (select * from idx1 i where o.c1 = i.c1);C1         |C2         |C3         -----------------------------------1          |2          |3          ij> values SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS();1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Statement Name: 	nullStatement Text: 	-- simple EXISTSselect * from outer1 o where exists (select * from idx1 i where o.c1 = i.c1)Parse Time: 0Bind Time: 0Optimize Time: 0Generate Time: 0Compile Time: 0Execute Time: 0Begin Compilation Timestamp : nullEnd Compilation Timestamp : nullBegin Execution Timestamp : nullEnd Execution Timestamp : nullStatement Execution Plan Text: Project-Restrict ResultSet (4):Number of opens = 1Rows seen = 1Rows filtered = 0restriction = falseprojection = true	constructor time (milliseconds) = 0	open time (milliseconds) = 0	next time (milliseconds) = 0	close time (milliseconds) = 0	restriction time (milliseconds) = 0	projection time (milliseconds) = 0Source result set:	Nested Loop Exists Join ResultSet:	Number of opens = 1	Rows seen from the left = 2	Rows seen from the right = 1	Rows filtered = 0	Rows returned = 1		constructor time (milliseconds) = 0		open time (milliseconds) = 0		next time (milliseconds) = 0		close time (milliseconds) = 0	Left result set:		Table Scan ResultSet for OUTER1 at serializable isolation level using share table locking chosen by the optimizer		Number of opens = 1		Rows seen = 2		Rows filtered = 0		Fetch Size = 16			constructor time (milliseconds) = 0			open time (milliseconds) = 0			next time (milliseconds) = 0			close time (milliseconds) = 0			next time in milliseconds/row = 0		scan information: 			Bit set of columns fetched=All			Number of columns fetched=3			Number of pages visited=1			Number of rows qualified=2			Number of rows visited=2			Scan type=heap			start position: null			stop position: null			qualifiers:None	Right result set:		Index Scan ResultSet for IDX1 using index IDX1_1 at serializable isolation level using share row locking chosen by the optimizer		Number of opens = 2		Rows seen = 1		Rows filtered = 0		Fetch Size = 1			constructor time (milliseconds) = 0			open time (milliseconds) = 0			next time (milliseconds) = 0			close time (milliseconds) = 0			next time in milliseconds/row = 0		scan information: 			Bit set of columns fetched={0}			Number of columns fetched=1			Number of deleted rows visited=0			Number of pages visited=2			Number of rows qualified=1			Number of rows visited=1			Scan type=btree			Tree height=1			start position: 	>= on first 1 column(s).	Ordered null semantics on the following columns: 			stop position: 	> on first 1 column(s).	Ordered null semantics on the following columns: 			qualifiers:Noneij> -- simple ANY

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -