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

Reimplement the session mode #197

Open
auxten opened this issue Feb 8, 2024 Discussed in #196 · 6 comments · Fixed by #283
Open

Reimplement the session mode #197

auxten opened this issue Feb 8, 2024 Discussed in #196 · 6 comments · Fixed by #283
Assignees
Labels

Comments

@auxten
Copy link
Member

auxten commented Feb 8, 2024

Current chDB(till v2.0.2) relys on temp disk storage to keep the session data.
Everytime session.query runs almost everything in memory will be recreated and reinit which caused a lot of state problems like:

Also some feature implemented and bugs walked around before also need a better way to fix:

Some chDB contributor also gave a try to make session better:

Originally posted by l1t1 February 7, 2024

:) create table a engine=Memory as select 1 a;

0.11995077133178711
:) select * from a;
Code: 60. DB::Exception: Table _local.a does not exist. (UNKNOWN_TABLE)

0.11473512649536133

Here is how clickhouse-local interactive mode works:

root@0a8b55995b6e:/auxten/chdb/tests# ./ch24.5/usr/bin/clickhouse
ClickHouse local version 24.5.1.1763 (official build).

0a8b55995b6e :) create table a engine=Memory as select 1 a;

CREATE TABLE a
ENGINE = Memory
AS SELECT 1 AS a

Query id: 967a5d72-bb39-4a42-8a11-a108eda2a5d9

Ok.

0 rows in set. Elapsed: 0.008 sec. 

0a8b55995b6e :) select * from a;

SELECT *
FROM a

Query id: e5be6b9b-b752-4418-8753-adb8cc69a127

   ┌─a─┐
1. │ 1 │
   └───┘

1 row in set. Elapsed: 0.008 sec. 

The good part are:

  1. Better support for states like 'Memory Table Engine', 'UDF', 'SET', 'USE'
  2. Less tricky code to handle default database and 'SET', 'USE' statements
  3. Without load tables and do init on every query function call, Performance should be much better than current implementation
@auxten
Copy link
Member Author

auxten commented Sep 4, 2024

All issues with label Session is related to this feature

#225
#258
#261
chdb-io/chdb-node#18

@auxten auxten changed the title Reimplement the session mode to support Memory engine Reimplement the session mode Sep 4, 2024
@auxten
Copy link
Member Author

auxten commented Sep 4, 2024

Here is the rough plan:

  1. Upgrade engine to 24.8 or newer, as ClickHouse engine did a lot of bugfix and optimization on clickhouse-local in recent 3 releases
  2. Better handling BackgroundSchedulePool and all kinds of Context
  3. Reimplement the session mode

@ruslandoga
Copy link

ruslandoga commented Nov 6, 2024

👋 @auxten

Would it also support stale parts cleanup #107?

And, in general, full use of MegreTrees (writing, parallel reading, etc.) https://github.com/orgs/chdb-io/discussions/210#discussioncomment-8863924

@auxten
Copy link
Member Author

auxten commented Nov 6, 2024

👋 @auxten

Would it also support stale parts cleanup #107?

Yes, I think so

@raystyle
Copy link

👋 @auxten
Would it also support stale parts cleanup #107?

Yes, I think so

If it is not possible to merge partitions, each append operation will cause the partition to keep expanding.

@auxten
Copy link
Member Author

auxten commented Nov 20, 2024

👋 @auxten
Would it also support stale parts cleanup #107?

Yes, I think so

If it is not possible to merge partitions, each append operation will cause the partition to keep expanding.

Yes, It's a serious problem in current impl. In this new impl, there will be some background threads doing the merge work periodically.

@github-project-automation github-project-automation bot moved this from In Progress to Done in chDB 2024 Q4 Nov 23, 2024
@auxten auxten reopened this Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants