Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Help, RDBMS have taken over my brain!

by Beechbone (Friar)
on Nov 24, 2004 at 13:24 UTC ( [id://410127]=note: print w/replies, xml ) Need Help??


in reply to Re: Help, RDBMS have taken over my brain!
in thread Help, RDBMS have taken over my brain!

I always wanted to code a forum that stores the bodies in a table like

PartID, MessageID, ThreadID, BodyPart VARCHAR(254)

so one could select a message with:

SELECT BodyPart FROM Body WHERE MessageId=? ORDER BY PartID

and all messages of a thread with:

SELECT MessageID, BodyPart FROM Body WHERE ThreadId=? ORDER BY MessageID, PartID

and get a preview of a message with:

SELECT BodyPart FROM Body WHERE MessageId=? where PartID=0

Fulltext search with preview:

SELECT MessageID, ThreadID, BodyPart FROM Body WHERE BodyPart LIKE '%foo%' ORDER BY MessageID

or, or, or... :-)


Search, Ask, Know
  • Comment on Re^2: Help, RDBMS have taken over my brain!

Replies are listed 'Best First'.
Re^3: Help, RDBMS have taken over my brain!
by mpeppler (Vicar) on Nov 24, 2004 at 14:46 UTC
    That's all good (well, modulo a minor normalization quibble), except the full text search:
    select ... from ... where BodyPart like '%foo%' ...
    On a small dataset this will be OK, but it won't scale, as it requires a table scan (or at the very least a full index scan if BodyPart is indexed) for databases that use B-Tree (and derived) indexes due to the leading wild-card (%).

    Michael

      better (mysql at least) putting a fulltext index on BodyPart and use:
      MATCH(BodyPart) AGAINST('foo')

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://410127]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found