Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support temporary table #1248

Closed
zimulala opened this issue May 23, 2016 · 4 comments
Closed

Support temporary table #1248

zimulala opened this issue May 23, 2016 · 4 comments
Labels
feature/accepted This feature request is accepted by product managers type/compatibility type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@zimulala
Copy link
Contributor

zimulala commented May 23, 2016

  1. What did you do?
    create temporary table t1( n int);

2.What did you expect to see?
Query OK, 0 rows affected (0.00 sec)

3.What did you see instead?
ERROR 1105 (HY000): line 1 column 8 near "temporary"

It can refer to MySQL Doc

@zimulala zimulala added the type/enhancement The issue or PR belongs to an enhancement. label May 23, 2016
@zimulala zimulala added type/new-feature and removed type/enhancement The issue or PR belongs to an enhancement. labels Feb 13, 2020
@zimulala
Copy link
Contributor Author

Currently, we only support syntax, there is no real support for temporary table.

@zz-jason zz-jason added type/feature-request Categorizes issue or PR as related to a new feature. and removed type/new-feature labels Mar 31, 2020
@zz-jason
Copy link
Member

zz-jason commented Jul 29, 2020

One use case in the batch process:

create a temporary table in each session:

create temporary table tmp(a bigint, b bigint);

concurrently execute the following transaction:

begin;

-- clear the tmp table.
truncate table tmp;

-- fill the tmp table.
insert into tmp select a, b from t where <condition> order by <primary_key> limit <batch_size> for update;

-- some select queries on the tmp table.
select ...

-- update the base table based on the same condition, the order by clause ensures the same batch.
update t set <change_some_status_field> where <condition> order by <primary_key> limit <batch_size>;

commit; -- or rollback.

@zz-jason zz-jason added feature/reviewing This feature request is reviewing by product managers feature/discussing This feature request is discussing among product managers and removed feature/reviewing This feature request is reviewing by product managers labels Aug 6, 2020
@zz-jason zz-jason added feature/accepted This feature request is accepted by product managers and removed feature/discussing This feature request is discussing among product managers labels Aug 15, 2020
@zz-jason
Copy link
Member

zz-jason commented Oct 9, 2020

another use case for the temporary table feature is to improve the performance of pagination:

  • store the result in the session temporary table
  • retrieve data from the session temporary table of each page

It avoids scanning the underlying table for each page, which can both improve the performance of pagination and reduce the resource utilization in the whole TiDB cluster.

@djshow832
Copy link
Contributor

Duplicate with #24169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/accepted This feature request is accepted by product managers type/compatibility type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

4 participants