Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3601720
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:39:24+00:00 2026-05-18T20:39:24+00:00

This might be a basic question: I am using a temporary table in some

  • 0

This might be a basic question: I am using a temporary table in some of my php code like so:

  1. CREATE TEMPORARY TABLE ttable( `d` DATE NOT NULL , `p` DECIMAL( 11, 2 ) NOT NULL , UNIQUE KEY `date` ( `date` ) );
  2. INSERT INTO ttable( d, p ) VALUES ( '$d' , '$p' );
  3. SELECT * FROM ttable;

As we scale up our site, will this ever be a problem? ie, will user1’s ttable & user2’s ttable ever get mixed up & user1 sees user2’s ttable & vice versa? Is it better to create a unique name for each unique temporary table?

thx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:39:25+00:00Added an answer on May 18, 2026 at 8:39 pm

    It is almost always better to find a different way than using temporary tables.

    The only time I would consider them is under the following conditions:

    1. The activity is rare. Meaning, a given user MIGHT do this once a week.
    2. It is used as a holding container prior to doing a regular full import of data.
    3. It deals with data whose structure is unknown prior to being filled.

    All three of those really go with building some type of generic bulk import routines where the data mapping is defined at run time.

    If you find yourself creating temp tables frequently in the application, there’s probably a better way.

    Scalability is going to depend on the amount of data being loaded and frequency of temp table usage. For a low trafficked site it might be okay.

    We’re in the process of ripping out a ton of temp table usage by a client’s app. 90% of the queries in their system result in a temp table being created. Analysis of all the queries have shown that the original dev used this mechanism simply because they didn’t understand SQL. We’re doing this because performance has radically dropped off as new users are added to the system.

    Can you post a use case? Maybe we can help provide an alternate mechanism.

    UPDATE:

    Now that we have a use case, here is a simple table structure to accomplish what you need.

    Table ZipCodes
    ZipCode char(5) [or char(10) depending on need]
    CityName varchar(50)
    *other columns as necessary such as latitude or whatever.

    Table TempReadings
    ZipCode char(5) [foreign key to the ZipCode table]
    ReadingDate datetime
    Temperature float (or some equivalent)

    To get all the temp readings for a given zip code you would do something like:

    select ZipCode, ReadingDate, Temperature  
    from TempReadings
    

    if you need info from the main ZipCode table:

    select Z.ZipCode, Z.CityName, TR.ReadingDate, TR.Temperature
    from ZipCodes Z 
    inner join TempReadings TR on (TR.ZipCode = Z.ZipCode)
    

    add where clauses as necessary. Note that none of the above requires having a separate table per zip code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a basic question: I am using a temporary table in some
This might look like a basic question to some of you but I expect
This might not appear like a programming question, but inherently deals with code. I
this is might be a very basic question, but seems like it's not easy
This might be basic question but how do I create a list of lists
This might be basic question, however I am confused on some .Net Concpets. I
I know, this might be a very basic question but I am not 100%
This might seem like a very easy question for some of you folks, but
I'm not sure how to describe this, but I'll try with some basic code:
This might seem like a silly question, but after asking some questions on stackoverflow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.