Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [temporary-tables]

The use of temporary table objects (not table variables) including semantics, design, performance optimization, and indexing. See also [table-variable].

1
vote
1answer
25 views

Why can't temporary tables reference regular (non-temp) tables in PostgreSQL?

Why can't temporary tables references non-temp tables in PostgreSQL? When I run the following CREATE TABLE foo ( a int PRIMARY KEY ); CREATE TEMP TABLE bar ( a int REFERENCES foo ); I get, ERROR:...
2
votes
1answer
49 views

What types of locks are held on global temporary tables?

I am wondering if: the isolation level is Read Committed data is inserted or deleted or read are the same locks (shared for reading and exclusive for insert/delete) used for global temporary table ...
7
votes
1answer
158 views

Using `min_active_rowversion` for global temporary tables

I use global temporary tables for easy integration testing of my SQL Server backed application. But the function min_active_rowversion does not seem to include global temporary tables, like seen ...
1
vote
1answer
45 views

How to create and fill multiple session temp tables with dynamic SQL?

I have a column that holds JSON data. The table can be filtered for sets of similar JSON data that will have mostly identical JSON keys in the JSON column. I can dynamically collect the set of JSON ...
9
votes
1answer
272 views

logical reads on global temp table, but not on session-level temp table

Consider the following simple MCVE: SET STATISTICS IO, TIME OFF; USE tempdb; IF OBJECT_ID(N'tempdb..#t1', N'U') IS NOT NULL DROP TABLE #t1; CREATE TABLE #t1 ( r int NOT NULL ); IF OBJECT_ID(N'...
0
votes
1answer
40 views

Safe to use the same temporary table name in parallel transactons?

Using postgreSQL 10 or 11, would it be safe creating temporary tables with the same name, each carrying different data? I do not intend to share the data between any sessions/connection/transactions. ...
0
votes
1answer
68 views

executing SQL query with temp tables using 1.6jdk

I created a batch to run a query that has temp tables as the below example IF OBJECT_ID ('tempdb..#TEMP1') IS NOT NULL DROP TABLE #TEMP1 select * into #TEMP1 from cutomer IF OBJECT_ID ('tempdb..#...
2
votes
1answer
198 views

How to clear temp database content in SQL Server?

As the title implies, I am going to clear the content of my temp database in SQL Server. SolarWinds is generating a critical alert and I want to clear the tempdb workfiles and worktables. How can I ...
5
votes
3answers
551 views

How to inspect global temp table from outside the transaction it is created in

To help debugging a batch of SQL (that is run inside a transaction), inside the transaction I dump some data into a global temporary table. The global temporary table is created inside the transaction ...
0
votes
0answers
109 views

PostgreSQL Optimize bulk values CTE and SELECT INTO TEMP TABLE to prevent OOM kills

Recently we moved some code from Rails way to raw SQL for performance reasons. We have some jobs which fetch some data from APIs, data can be in 100K+ rows of count sometimes. This data needs to be ...
0
votes
2answers
44 views

MariaDB Spider Engine UDF spider_bg_direct_sql can't find TEMPORARY table

I am testing the Spider engine in MariaDB. In version mariadb-10.1.12-linux-x86_64 the UDF works, but there are some issues so I want to upgrade to a newer version. However, mariadb-10.2.18-linux-...
7
votes
4answers
626 views

Does LocalDB support temporary tables?

Are SQL Server temporary tables (prefixed with #) supported in LocalDB instances?
0
votes
0answers
30 views

MySQL 8 using the wrong tmp directory

I have a query like so... INSERT INTO table3 SELECT DISTINCT * FROM table1 LEFT JOIN table2 on ... And it uses a temp table. The query runs for about 60 seconds, then starts filling /tmp even ...
0
votes
2answers
67 views

INNER JOIN is extremly slow on some rows and create temp table

The MySQL query SELECT `p`.*, `p.Author`.* FROM `post` AS `p` INNER JOIN `user` AS `p.Author` ON `p`.`userid` = `p.Author`.`userid` WHERE ( ( `p`.`threadid` = 29780 ) AND ( `...
0
votes
1answer
32 views

Temp tables not being created in SQL Server Azure [duplicate]

I have created a stored procedure that creates multiple temp tables for use in the sproc and then drops them at the end of the sproc. The problem I am encountering is I can execute the stored ...
1
vote
1answer
829 views

“The transaction log for database 'tempdb' is full due to 'ACTIVE_TRANSACTION'.” after adding indexes to temp tables

Recently, I added some indexes on temp tables to procedures which prepare data for data warehouse. On a testing db, tests of these procedures worked fine but when running on client's server it failed ...
1
vote
1answer
630 views

Performance difference between Text and Varchar in Mysql

I was experimenting with text and varchars in mysql 5.7. I create a simple mysql table as below CREATE TABLE small_table ( pk int(11) NOT NULL AUTO_INCREMENT, varc varchar(255) DEFAULT NULL, txt ...
1
vote
1answer
37 views

Finding temporary table name in MariaDB

As I reported some days ago to MariaDB bug tracker the following bug: https://jira.mariadb.org/browse/MDEV-17420, slave replicas with version 10.2.x are leaking temporary tables on MyISAM files. Our ...
1
vote
2answers
24 views

mysql - calculate traffic for tmp tables

I'm thinking of placing tmpdir to SSD - to increase speed of working with sorting data in tmp tables on disk. Our base creates a lot temporary tables on disk during sorting, merging, joining an so on. ...
0
votes
1answer
15 views

Dropping rows based on the previous selection statmnet

I have a database with following tables: temp_1, temp_2.... and cached_tbl. Inside cached_tbl I have column table_name and in corresponding rows I store all the temp table names I mentioned above. SO ...
0
votes
1answer
235 views

Truncating TEMP table before insert leads to big amount of logical reads on TEMP TABLE

Setup: We have a complex set of queries, that runs quite often (about 3000 times per hour) for different users. At the start of the process, .NET application creates a set of temp tables during the ...
1
vote
1answer
202 views

Why do LocalTemp table showing with lengthy underscore under Temporary Tables of tempdb in SSMS 2017 Express Edition? [duplicate]

In my Microsoft SQL Server 2017 Express Edition, I have created a local temp table using below create statement, create table #localtemptable (tempid int,tempname varchar(20) ) After creating #table,...
3
votes
1answer
113 views

Reasons for not Globally enabling Trace Flag 2453 - Cardinality on Table Variables

I've been doing some reading on the improvements that Trace Flag 2453 can give on the performance of Table Variables by maintaining statistics and was wondering what would be the reasons you would ...
4
votes
2answers
120 views

Temp Table Filtered Index Creation is Blocked When Stored Procedure is Run Multiple Times Concurrently

Are there any known blocking issues in SQL Server 2014 that are specific to creating one or more filtered indexes on a temp table after the initial table creation? (i.e. not an inline index creation) ...
1
vote
0answers
62 views

Why does the Select statement stalls when executed directly in sequence?

When executing the following in workbench or in code, the Drop table/Create Table works ok. The Select statement stalls when executed in one go. If the table is MyIsam, it works ok. If executed [...
3
votes
1answer
2k views

MS SQL Server: Do multiple queries in a batch ever execute in parallel and if so what happens when the second query is dependent on the first?

If I have a batch of two different SELECT statements, is it possible for them to be executed in parallel (if the SQL Optimizer deems it to be the most efficient execution method)? If the first SELECT ...
0
votes
1answer
34 views

How to get the consolidated ServiceID with the sum of File Size associated with over an year

Can anyone please help me on below to get the consolidated ServiceID with the sum of File Size associated with it over an year. Complete Code (For reference) If(OBJECT_ID('tempdb..#temp1') Is Not ...
0
votes
1answer
574 views

Where is `pg_temp` documented in the PG manual?

I have tried various ways to search for pg_temp in the manual, but could not find it. Is it documented in the manual?
0
votes
2answers
244 views

How to get around not being able to use Temp Tables in Functions?

So, to get straight to the point. A Client wants to be able to view all of their staff of a certain position are going to be available to perform a set of shifts between 2 dates. Seems simple, have a ...
0
votes
1answer
564 views

mysql memory temp table creation SLOW

I'm trying to get to the bottom of what I'm thinking is a performance issue when creating in memory temporary tables. The underlying query I have looks to me to be pretty well optimized. The explain ...
5
votes
1answer
552 views

Why is it not possible to create indexes on temp tables in SNAPSHOT isolation?

When I try to create indexes on a temporary table in SQL Server when using the SNAPSHOT transaction isolation, I get this error: Transaction failed because this DDL statement is not allowed inside ...
1
vote
2answers
1k views

Can multiple instance of procedure create same #Temp simultaneously?

I have a procedure which is inserting data into #temp table. After performing certain manipulations to the data, it store data from #temp table to some other table. I cannot run multiple instance of ...
3
votes
1answer
139 views

Tempdb size strategy

I've recently started my role as a DBA and my initial task has been to take ownership and redeploy a database provided by a 3rd party to help us conform to GDPR legislation. As a consequence, I've ...
0
votes
0answers
88 views

Temporary tablespace size in 12C

I have installed 12C and importing data through sqlldr , but it increases the temporary tablespace size tremendously which causing the oracle shutdown. Please help and guide me what to do to get rid ...
0
votes
1answer
460 views

How to find index details on Temporary tables in SYBASE

I am a layman in SYBASE world. In order to improve performance, I am creating indexes after data load of temporary tables in many stored procedures. Say, one proc A has an insert into temporary ...
1
vote
3answers
395 views

I ran MySQLTuner and wondered if anyone would go over the results with me, specifically query cache and temporary tables

Here are the results of MySQLTuner: [--] Skipped version check for MySQLTuner script [OK] Logged in using credentials from debian maintenance account. [OK] Currently running supported MySQL version 5....
2
votes
2answers
551 views

Issue while trying to insert the values into a temp table from a query

Please help me on below . I am trying to insert values into a temp table using the sql query. But I am facing below errors . Please help me understand the mistakes. Errors I am facing : Database ...
0
votes
1answer
51 views

New Analyst SQL Optimization - Multiple Spools

Unfortunately my ability to Query has outgrown my knowledge of SQL Optimization, so i am hoping someone would help a young analyst by looking at this atrocious execution plan and provide some wisdom ...
1
vote
1answer
248 views

How to check if a PostgreSQL table is temporary?

How can I write a query to check if a PostgreSQL (10.x) table is a temporary table? I looked at the pg_class system table, but couldn't find any column about whether the relation is temporary. ...
3
votes
0answers
612 views

How to put an execution time limit for MySQL Temporary table creation

We can use SET MAX_EXECUTION_TIME=10; statement to stop the execution of a SELECT statement, if it took more than 10 milliseconds to execute the query. But the same wont work for other statements like ...
2
votes
1answer
104 views

INSERT MASTER.sys.sysdatabases result into a temporary table

I have this query that iterate all databases on my SQL Server DECLARE @DB_Name varchar(100) DECLARE @Command nvarchar(200) DECLARE database_cursor CURSOR FOR SELECT name FROM MASTER.sys....
1
vote
1answer
226 views

DELETE … IN hangs after deleting half of a large table (even for deleting 10 rows)

I'm having trouble with a DELETE hanging, even for a small number of rows (10) in a large MariaDB InnoDB table. Background I had a large table (~400,000,000 rows) that needed to have rows archived ...
2
votes
1answer
517 views

MEMORY_OPTIMIZED table as replacement for temporary tables

I use temporary tables for complex processing which is done in several "child" procedures. These procedures are working in the same session, so the temp tables are accessible for them. Is there a ...
1
vote
1answer
21 views

Find rows where column matches one of n strings [closed]

I am trying to find the best way to see if multiple email addresses already exist in my database. I have a table with member id's, emails, and other info, and I need to import members but to check if ...
3
votes
2answers
219 views

SQL Server Temporary Table Security

I am part of a project to convert an old AS400 system to SQL server. The server is used for our payroll processing. Part of the payroll process is to break out the percentage of the biweekly wages ...
2
votes
1answer
1k views

How to find MySQL creating temporary table in memory or disk?

I have a query, after running it if i run the show status in the same session like below show status where Variable_name like '%Created_tmp_disk_tables%'; It got incremented by one value. So it ...
1
vote
1answer
198 views

Loop INSERT EXEC AT through linked servers

Relating to Inserting EXEC AT linked server into temp table I am now in the midst of dynamically insert each result of dynamic sql to the temp table for each registered linked server. Below is my ...
1
vote
1answer
4k views

Using INSERT INTO…EXEC AT linked server into temp table fails with Msg 7391

I am using SQL Server 2014. I want to execute EXEC (@remotecmd) AT [server_name]; (@remotecmd is a dynamic sql not a stored procedure) into ##eapb. My code is insert into ##eapb EXEC (@remotecmd) AT [...
0
votes
1answer
53 views

Temp table lives after being explicitly dropped [duplicate]

I'm creating a post-deployment script in VS2017 database project. In this script, I'm using single temp table, which is re-created frequently to adjust to different data structures. Below you can see ...