• Welcome to Valhalla Legends Archive.
 

Creating a Priority Queue Discussion

Started by Hazard, August 06, 2003, 02:04 PM

Previous topic - Next topic

What do you think of the idea outlined below? Do you like the idea?

Yay
11 (64.7%)
Nay
6 (35.3%)

Total Members Voted: 6

Banana fanna fo fanna

Quote from: Camel on August 09, 2003, 10:13 PM
           With ExecSQL("SELECT TOP 1 id, text " & _
                        "FROM buffer " & _
                        "ORDER BY priority DESC, " & _
                                 "id ASC" & _
                        ";")


Do you know how incredibly absofuckingloutly slow that is compared to an in-memory datastructure!? That's such a waste of processing power, probably the string concatenation to build the query has more cycles than a priority queue, not to mention the overhead of sending the query to the database if it is remote, and the parsing of the query string, and the loooong expensive execution of the query, and then parsing back of the result.

In my old chatbot (PhatBot, circa 2000/2001), I implemented a priority queue once to try it out. Basically, I gave anything that started with a / precedence over any normal commands. This didn't work out too well; it was confusing. Instead, I propose any commands or whatever should be queued with a higer priority.

Camel

Quote from: St0rm.iD on August 10, 2003, 10:22 AMDo you know how incredibly absofuckingloutly slow that is compared to an in-memory datastructure!?

Yes; it is relatively slow. However, it's not too slow to use in practice. Additionally, I don't actually put everything in the sql table; there is a seperate internal buffer -- that buffer is ignored until the internal buffer is empty.

Banana fanna fo fanna

Yeah, but why even use SQL? It's not that hard to write a priority queue, you could probably get one on pscode if you wanted to.

DarkMinion

That seems to me it would be *far* more inefficient than simply having an internal queue in memory Camel....

Camel

Quote from: St0rm.iD on August 10, 2003, 05:13 PMYeah, but why even use SQL?

For one, so I can click people out of the channel from the website. That buffer wont be just for chat messages when I finish it, either.
http://camel.ik0ns.com:400/