Page 2 of 2

Re: Searching

Posted: Sun Nov 27, 2011 12:56 pm
by tappatekie
Rebornxeno wrote:How do you find the book your looking for in a library? Maybe the two things aren't much different! :O
You make it sound simple...

Re: Searching

Posted: Sun Nov 27, 2011 3:30 pm
by superLED
Rebornxeno wrote:How do you find the book your looking for in a library? Maybe the two things aren't much different! :O
What, to ask the librarian?
In the programming world, it would be like asking MySql to find our stuff 8)

Re: Searching

Posted: Sun Nov 27, 2011 3:35 pm
by LeonBlade
superLED wrote:
Rebornxeno wrote:How do you find the book your looking for in a library? Maybe the two things aren't much different! :O
What, to ask the librarian?
In the programming world, it would be like asking MySql to find our stuff 8)

Code: Select all

askDatabaseLibrarian("WHERE IS THE ROW FOR THE ONE GUY I WANT");
It's just that easy.

Re: Searching

Posted: Sun Nov 27, 2011 4:01 pm
by superLED
LeonBlade wrote:
superLED wrote:
Rebornxeno wrote:How do you find the book your looking for in a library? Maybe the two things aren't much different! :O
What, to ask the librarian?
In the programming world, it would be like asking MySql to find our stuff 8)

Code: Select all

askDatabaseLibrarian("WHERE IS THE ROW FOR THE ONE GUY I WANT");
It's just that easy.
Yep, life's easy!

Re: Searching

Posted: Sun Nov 27, 2011 4:15 pm
by tappatekie
No I mean to actually find the entry in the first place without the help SQL

Re: Searching

Posted: Sun Nov 27, 2011 5:41 pm
by dandymcgee
tappatekie wrote:No I mean to actually find the entry in the first place without the help SQL
Yeah, I think they were making fun of Rebornxeno's absurd response.

Re: Searching

Posted: Sun Nov 27, 2011 6:03 pm
by tappatekie
Ah okay.
I have destroyed the dark cloud that hung over the source files (commenting the code) so now I am developing the first stages of the database overhaul to make searches alot more faster (from advice from this thread)

Thanks

I don't expect the database system to be as good as SQL. But as it will be, everything database related on the site will link to 1 single API which helps the communication with the actual database server with my own protocol.
But if the server becomes slow as we (hopefully) get more users, posts etc, then we will think about using the SQL server and incorporate it with the database API's which will be a great help since we don't need to even touch the site code to convert it to SQL :D

Re: Searching

Posted: Sun Nov 27, 2011 6:42 pm
by Rebornxeno
If you organize the database, searches are pretty fast regardless of its size.

Re: Searching

Posted: Sun Nov 27, 2011 6:54 pm
by tappatekie
Rebornxeno wrote:If you organize the database, searches are pretty fast regardless of its size.
How do you mean "organize"?, as in their all sorted?. If so that's all covered

I am working on having the database structured like this

[table identifier token (tells the parser that it's a table) (byte[])][/table]
[column count (byte)][/column]

[entry address (byte[])]
[entry length[])][/entry]
[/entry]

[entry]
[entry1 value(byte[])][/entry]
[entry2 value (byte[])][/entry]
[/entry]

The tags are there for simplicity, they wont be in the actual file. Also the byte[] values for the numeric value types basically allow me to use numbers bigger than 255 (see previous posts for more info)

Re: Searching

Posted: Sat Jan 07, 2012 11:32 am
by tappatekie
Okay I have looked into BST's a bit more since I am re-writing every system I had (e.g Web Server) to have better performance.
I have come up with this solution to speed up the searching process and note that the search process will take place mainly for finding usernames.
Image

Every circle represents a reference to an entry in the database (index) (or just a link) and every time someone searches it follows these steps
Search Hello
Find H in the global tree root
> Okay found H (is it found? [no])
Find e
> Okay found e from the node list in H
etc....

Oh and by the way, there should also be a link between H and e with the green link as well..

I have'nt began coding it but I believe it will be a faster alternative than a linear search. So if you have believe that this will be as slow then please reply.

Re: Searching

Posted: Sat Jan 07, 2012 1:43 pm
by dandymcgee
tappatekie wrote:I have'nt began coding it but I believe it will be a faster alternative than a linear search.
Binary search is most certainly faster than linear search. However, you may want to look into hashed indexes and B-Trees.

Re: Searching

Posted: Mon Jan 09, 2012 4:03 am
by tappatekie
Okay thanks for advice.