Tables used to store transient data.

learn more… | top users | synonyms

5
votes
0answers
70 views

Benefit or use-case for empty variable / parameter / temporary table / temporary procedure names?

I just discovered, through sheer brilliance accidentally, that SQL Server allows you to create variables, parameters, table variables, temporary tables (local and global), and temporary stored ...
5
votes
1answer
81 views

Conditionally add an index to a temp table

I have a stored procedure that looks something like this: SELECT columnlist INTO #temptable FROM Table JOIN lotsofothertables WHERE severalconditions UPDATE anothertable SET column = ...
7
votes
1answer
88 views

how come a table variable is improving the performance of a query in this circumstance?

for this specific case, that I will try to explain below, using a table variable is performing better than not using a table variable. I would like to know why, and if possible, get rid of the table ...
6
votes
2answers
108 views

XML parsing slowly

I'm currently trying to tune a somewhat problematic stored procedure and I've noticed that majority of cost associated with running it comes from parsing parsing some XML into a temp table. Here is ...
2
votes
1answer
25 views

Removing the uses of MySQL temporary tables

We have a very huge PHP/MySQL application with a lot of legacy code, this application utilized MySQL for most of it's work. It does most of the processing on the database side using temporary tables, ...
0
votes
1answer
26 views

Mysql takes more tmp space than the table size

I have a mysql table with 2.8GB data+index size. I wanted to add a column to the table and it was failing due to insufficient space on /tmp. When I looked at the size available on /tmp it was 3.9GB. ...
4
votes
1answer
105 views

Insert results from a stored procedure into a table variable

I have a stored procedure that stores values in a table variable. I select these values and return them when the procedure is called. I am trying to set these return values in another table variable ...
0
votes
1answer
46 views

TEMP table alternatives for pl/pgsql

I am trying to emulate MERGE behavior with pl/pgsql: -- Generate the data from funtion CREATE TEMP TABLE temp_x (id int, id2 int, data text, created_at timestamp, updated_at timestamp) ON COMMIT ...
8
votes
1answer
92 views

Does SELECT INTO Reserve the #Object Name in TempDB Prior to Runtime?

Putting together a quickie proc to help with debugging, I ran into a what seems to be a error in the compiler. create proc spFoo @param bit as begin if @param = 0 begin select * ...
4
votes
2answers
74 views

Are temp tables automatically created when referencing to them?

I can across the following script and I am trying to understand it. select columnA, columnB, columnC into #tmpTable from tableA The #tmpTable is referenced after that query, but not before it. ...
1
vote
1answer
161 views

Postgres 'could not write to hash-join temporary file: No space left on device'

I was getting this error a while ago and I was curious about two things - 1- How do the internals of postgres work that cause this message to occur in the first place? What is the hash-join in ...
3
votes
2answers
47 views

Why tmp tables created when connected to one database

I am wondering why temp tables created while switching to database. When I login to the mysql server, I have queried current session temp tables as follows: mysql> show status like '%tmp%'; ...
4
votes
1answer
106 views

Viewing Temp Tables

I am using SQL Server 2008 and my stored proceduce does inserts into #temptable. My procedure has been running for 32 hours (which isn't unheard of considering the amount of data that it has to ...
1
vote
3answers
101 views

Copy table structure excluding nullability into local temporary table

How can I copy the structure of a table into a temp table (or table variable) excluding the nullability of each column? Mainly I need to copy the column names and data types, but not nullability, ...
1
vote
0answers
145 views

CREATE TEMPORARY TABLE, temp_buffers and Postgres performance

I have a bunch of queries that use temporary tables, and most of them are working really good, but from time to time they take an usual amount of time: 3-5 seconds. My temp_buffers is set to the ...
0
votes
1answer
211 views

Simply inserting to temp table and failing

Can anyone tell me why this won't work for me? CREATE TABLE #UndistributedCmds ( pendingcmdcount int, estimatedprocesstime INT ) INSERT INTO #UndistributedCmds EXEC ...
6
votes
2answers
175 views

sys.dm_sql_referenced_entities fails to provide used columns list when joining with temp table

I think I need some help as I run out of ideas. In my database I have a simple table like this: CREATE TABLE dbo.Invoices ( CashDiscounts MONEY, Cost MONEY ) GO and a stored ...
0
votes
1answer
493 views

How to load Excel file into temp table in ORACLE

Is it possible to load a excel file with the headers into a temp table on Oracle? I use TOAD for the interface. I am needing to do some comparison on a a excel file with what we have in our ...
1
vote
1answer
2k views

How to add/update a column with an incremented value and reset said value based on another column in SQL

I am stumped, I have searched and researched until my browser tabs no longer show the close button ("X") until you hover over them. I tried rewriting the search term over and over but I guess I do not ...
3
votes
1answer
81 views

SSMS 2012 mutiple query windows using same session

I wonder if it is possible to connect multiple files or query windows in SSMS to one session? The reason is that I want to use local temporary tables that are created in one file/query-window in other ...
12
votes
2answers
1k views

Why is table variable forcing an index scan while temp table uses seek and bookmark lookup?

I am trying to understand why using a table variable is preventing the optimizer from using an index seek and then bookmark lookup versus an index scan. Populating the table: CREATE TABLE dbo.Test ...
0
votes
2answers
441 views

How can i update my database from another database using temporary tables?

I want to update tables of my database using another big database every day with using temporary tables and without returning result. How can i update it? This my temporary table : use data_pro; ...
3
votes
0answers
101 views

Why the stored procedure is much slower than a temporary table? [closed]

I want to do the updating of my database every day and I will like to use stored procedures but the time of execution of the temporary table is faster than the stored procedure. How can I optimize my ...
1
vote
1answer
451 views

Creating a global temp table in a SQL Agent job

I want to create a global temp table in a SQL Server Agent Job. Here is the code: CREATE TABLE ##TestEmployee(Id int, EmployeeName nvarchar(50)) When I execute in SSMS, all is well. I then put ...
1
vote
2answers
1k views

Global Temporary Table used in Stored Procedure executed concurrently across sessions

I use dynamic SQL in a stored procedure and must use a global temp table so the temp table and its data is available outside the instance when sp_executesql happens. I need the stored procedure to be ...
3
votes
2answers
101 views

Is copy/rename a good way to improve temp table performance?

An application I am working with contains this sequence of queries at the end of constructing a large temp table; I believe it is an attempt to improve performance by pruning dead tuples - create ...
1
vote
1answer
1k views

Can't Delete Orphaned MySQL Temp Table

One of my servers had a hick-up yesterday and decided to leave temporary table while (while running alter table add indexes). ls -l sql -rw-rw---- 1 mysql mysql 8570 Mar 13 12:05 #sql-ib32694.frm ...
1
vote
1answer
184 views

Unable to use a temporary table more than once [closed]

I am using SQL Server 2008 to build a stored procedure. In it, I create a temporary table (#results) using recursion for getting all the ancestors given a specific record. My specific problem is, ...
0
votes
2answers
335 views

Access Oracle GTT table data from another session?

I have using Oracle GTT tables with condition ON COMMIT DELETE ROWS. Now i know GTT tables data is only session specific. 1 session cannot see the GTT data of other session in General. But is their ...
1
vote
1answer
146 views

What's the best practice to avoid collisions in throwaway temp tables?

In SQL Server, I'm used to creating a #temp table for temporary storage in a complex stored procedure. Not wanting to clutter up the system, I DROP the table when done. However, if I do the same in ...
0
votes
0answers
66 views

Physical Table being used a Temp Table in a warehosue. Any advantage?

As I stated in previous posts I've inherited a warehouse based on SQL Server framework. In my continuous review of existing components and the practices adopted by the predecessors I found something ...
5
votes
3answers
7k views

Update statement is giving an invalid column name error, even though the column exists

I have a temporary table created at the beginning of this stored procedure. It is created successfully and can be selected from and inserted to. Here is the create statement CREATE TABLE ...
0
votes
1answer
307 views

Massive joins Vs Updating temp table

I'm working on a query that essentially aggregates a slew of tables together. The first method I tried was to inner join all of the tables into one nice big query that pretty much looked like this: ...
-1
votes
1answer
135 views

Statements in State “Copying to tmp table” disrupt performance [closed]

On a MySQL database (version 5.1.73) a Magento-Shop executes a statement (A) that uses distinct, see http://pastebin.com/A2sy45nF and therefore is "Using temporary" according to "explain". ...
3
votes
1answer
241 views

When is mariadb creating tmp tables?

I have found, that copying to tmp table is taking most of the time of a slow query, that I wanted to optimize. I watched the output of 'profiling' in a terminal. This happens on a pics table with 6000 ...
0
votes
0answers
77 views

MYSQL : Copying to TMP table nightmare

I'm having a (AFAIK) random issue. My server is MySQL and I have a query that is sometimes 10000 times slower as you can see on this screensot : http://snag.gy/vJJ39.jpg The long time occurs during 2 ...
0
votes
2answers
265 views

MySQL excessive tmp disk tables after Upgrade to 5.6

After upgrading two MySQL-Servers which run Master-Slave replication from Percona MySQL 5.5 to Percona MySQL 5.6 an excessive amount of temporary Tables gets created on the slave. The Master seems to ...
0
votes
2answers
220 views

reuse of temp table getting more time to execute

i'm creating temp table as, SELECT T.CD, T.OBJECT_CD, T.PRICE INTO #TEMP FROM TABLE_NAME T EDIT : ADDED CLUSTERED INDEX TO TEMP TABLE CREATE CLUSTERED INDEX IX_Temp_OBJECT_CD ...
0
votes
1answer
78 views

Large NOT IN Statement vs Creating/Populating Temp Table

I have a large daily data feed which can contain up to around 5,000 ID's. I need to delete all pre-existing records in the DB that are not referenced in the new feed. Should I create a temporary table ...
0
votes
1answer
1k views

Create and fill temp table

I have a stored procedure that selects some data and returns it. Now I also want to add a temp table, fill it with data and return it with the stored procedure. I define it as follows: create table ...
2
votes
1answer
2k views

Table Variable and Database Scope

I am a junior DBA, and I am still confused by database scope. Now I am learning about local/global temp table and table variables. I saw an example as following: declare @T1 as table ( col1 ...
0
votes
1answer
96 views

Create SP for inserting data from a table to a table

I have a table that has 1 record where one field may have 2 values separated by commas (in that cases I have to create 2 records with those values separated in 2 row and the other field values are the ...
1
vote
1answer
395 views

Table variable not Recognized in stored procedure

The following stored procedure for a postgresql database attempts to insert into a temporary table 'result' of type result_load_status ,which is a table in database, and return this temporary table. ...
1
vote
2answers
339 views

Is outputting to both a result set and a temporary table possible?

I have a stored procedure that I need to both output the result set to the user and use a piece of information in the result set to possibly output other result sets. Here is a basic schema of what I ...
1
vote
3answers
1k views

best practice for 'staging' relation in stored procedure: use temp table, or view?

When I write stored procedures that take relation A and output relation Z, I like to create 'staging' relations along the way, so I can inspect the state of the data after each step in the programming ...
1
vote
0answers
157 views

Using #temp to work around Reporting Services blocking issue

Having utterly failed to resolve why a perfectly acceptable but admitidly large stored procedure was suffering the blocking process lck_m_s when called via a report in SQL Reporting Services I have ...
1
vote
0answers
417 views

Inside stored procedure, set column names of returned query according to variable

I have a query which I'd like to reuse, instead of having many different copies of it just for the sake of changing the column name. The report (for example) uses the same query, but there are either ...
1
vote
1answer
616 views

Oracle temporary table usage with XA

I'm confused about the compatibility of Oracle XA with global temporary tables. I've read several places on the internet and in the oracle documentation that say "Distributed transactions are not ...
6
votes
2answers
1k views

Is this temp table behaviour documented?

Query Language (SQL) and PL/pgSQL functions treat temp tables differently: begin; create table foo(id) as values (1); select * from foo; /* id ---- 1 */ savepoint s; create function f() returns ...
2
votes
1answer
448 views

MySQL: does Index Merge Sort-Union access algorithm use temporary table?

My question is about index_merge optimization in MySQL. I have a query with a set of range conditions connected with OR. EXPLAIN of the query shows that index_merge method is used and the Extra ...