Open Chess Game Database Standard

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
phhnguyen
Posts: 1524
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Open Chess Game Database Standard

Post by phhnguyen »

amanjpro wrote: Fri Dec 10, 2021 4:21 am Probably a sort of table sharding will also speedup querying. Postgres IIRC has partition by on relations, one can use that to make your queries faster

https://www.postgresql.org/docs/10/ddl- ... oning.html
AFAIK, SQLite uses the same syntax as PostgreSQL but they are still different with different ways to use. I don't know (yet) how to apply that tech.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
amanjpro
Posts: 883
Joined: Sat Mar 13, 2021 1:47 am
Full name: Amanj Sherwany

Re: Open Chess Game Database Standard

Post by amanjpro »

phhnguyen wrote: Fri Dec 10, 2021 4:39 am
amanjpro wrote: Fri Dec 10, 2021 4:21 am Probably a sort of table sharding will also speedup querying. Postgres IIRC has partition by on relations, one can use that to make your queries faster

https://www.postgresql.org/docs/10/ddl- ... oning.html
AFAIK, SQLite uses the same syntax as PostgreSQL but they are still different with different ways to use. I don't know (yet) how to apply that tech.
I am not sure if SQLite has a built-in feature for partitioning. But one can always do it manually. Say create a parent table that maps hashes that are between 0 to N-1, to table 1. N to 2N-1 to table 2 and etc.

Your query might become two level, but you still might gain a lot of speed on average
User avatar
phhnguyen
Posts: 1524
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Open Chess Game Database Standard

Post by phhnguyen »

amanjpro wrote: Fri Dec 10, 2021 5:08 am
phhnguyen wrote: Fri Dec 10, 2021 4:39 am
amanjpro wrote: Fri Dec 10, 2021 4:21 am Probably a sort of table sharding will also speedup querying. Postgres IIRC has partition by on relations, one can use that to make your queries faster

https://www.postgresql.org/docs/10/ddl- ... oning.html
AFAIK, SQLite uses the same syntax as PostgreSQL but they are still different with different ways to use. I don't know (yet) how to apply that tech.
I am not sure if SQLite has a built-in feature for partitioning. But one can always do it manually. Say create a parent table that maps hashes that are between 0 to N-1, to table 1. N to 2N-1 to table 2 and etc.

Your query might become two level, but you still might gain a lot of speed on average
Oh, I see. Good idea. Will try. Thanks.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Open Chess Game Database Standard

Post by dangi12012 »

phhnguyen wrote: Fri Dec 10, 2021 5:22 am
amanjpro wrote: Fri Dec 10, 2021 5:08 am
phhnguyen wrote: Fri Dec 10, 2021 4:39 am
amanjpro wrote: Fri Dec 10, 2021 4:21 am Probably a sort of table sharding will also speedup querying. Postgres IIRC has partition by on relations, one can use that to make your queries faster

https://www.postgresql.org/docs/10/ddl- ... oning.html
AFAIK, SQLite uses the same syntax as PostgreSQL but they are still different with different ways to use. I don't know (yet) how to apply that tech.
I am not sure if SQLite has a built-in feature for partitioning. But one can always do it manually. Say create a parent table that maps hashes that are between 0 to N-1, to table 1. N to 2N-1 to table 2 and etc.

Your query might become two level, but you still might gain a lot of speed on average
Oh, I see. Good idea. Will try. Thanks.
This wont help. The problem is just that the position X is there 1E6 Times splitting wont help and is against sql fundamentals. Keep it in one table. We have to live with that i guess because you can see that 50ms is acceptable after ply 5
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Open Chess Game Database Standard

Post by dangi12012 »

Again the problem here is not that the hashes are not good but that we have so many duplicates like
01231
01231
01231
etc.. for 1e6 times.

If we limit to a single player or a group of players this problem goes away.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Sopel
Posts: 391
Joined: Tue Oct 08, 2019 11:39 pm
Full name: Tomasz Sobczyk

Re: Open Chess Game Database Standard

Post by Sopel »

who even needs millions of results, just slap LIMIT 100 on it and be done
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.

Maybe you copied your stockfish commits from someone else too?
I will look into that.
amanjpro
Posts: 883
Joined: Sat Mar 13, 2021 1:47 am
Full name: Amanj Sherwany

Re: Open Chess Game Database Standard

Post by amanjpro »

Sopel wrote: Fri Dec 10, 2021 2:37 pm who even needs millions of results, just slap LIMIT 100 on it and be done
Probably pagination instead of limit. But yeah limiting the resultset is the way to go
Dann Corbit
Posts: 12777
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Open Chess Game Database Standard

Post by Dann Corbit »

Here are some fide games with the hash:


Some issues:
We do not need the Elo in both the header and the player table, that is redundant.
The hash is interpreted as a 4 byte integer by the SQLite ODBC driver, even though it is stored correctly. (I added an index on the hash).
It might help as a hint to the ODBC driver if the type of the hash were changed to:
BIGINT or INT8 or (better yet) UNSIGNED BIG INT
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Dann Corbit
Posts: 12777
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Open Chess Game Database Standard

Post by Dann Corbit »

It would be nice to have a user defined function that can make the hash from a FEN/EPD.
That way we could do simple lookups like
SELECT gameid from hash where hash = makehash('rnbqkbnr/pppppppp/8/8/1P6/8/P1PPPPPP/RNBQKBNR b KQkq -')
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Open Chess Game Database Standard

Post by dangi12012 »

Dann Corbit wrote: Fri Dec 10, 2021 5:58 pm It would be nice to have a user defined function that can make the hash from a FEN/EPD.
That way we could do simple lookups like
SELECT gameid from hash where hash = makehash('rnbqkbnr/pppppppp/8/8/1P6/8/P1PPPPPP/RNBQKBNR b KQkq -')
I can write you one this evening. will update you! - I need the Table to exist which the HashCode is calculated from :)

Code: Select all

create table Zobrist(piece char, square integer, hash integer,
   primary key (piece , square)
);
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer