Perhaps.
The current implementation doesn't have to deal with PDO returning
text-based values for dates. Everything starts in an integer format
that can be worked with. It shouldn't be incumbent upon the datetime
class to account for idiosyncrasies between date storage and output of
each database engine, that should be a function of the data layer.
> However, from a data modeling viewpoint, implementing a date as a 32-
> bit number is horrible. In fact, for a so-called next generation piece
> of software, it's embarassing.
It makes me sad that this email is so critical now. The schema has been
on the list for months, and the branch has contained this code for weeks
before the recent merge.
To me, it's more important that the software functions efficiently than
it allows native engine function manipulation of date types. Still, if
there's a way to have database engines return a usable format - one that
isn't returned as a string we have to parse - and allows us to store the
data in a native date format, it may yet be useful to explore it.
Owen
I like the idea of storing timestamp ints for all dates. It does look
like the best bet for supporting different database platforms, and
actually makes search/retrieval faster while pushing more computation
out to the webserver.
I just launched a high-traffic site for a huge media company here in
Times Square that gets ~40 million page views weekly. I fretted the
entire time about application server performance, especially as it
used a totally object-driven MVC framework. The thing launched and
surprisingly enough, immediately became database bound,
throughput-wise.
It is a LOT easier to throw in more webservers, than it is to throw in
more database servers. Keeping the job on the database simple is a
really smart approach.
-- Mitch
It is a LOT easier to throw in more webservers, than it is to throw in
more database servers. Keeping the job on the database simple is a
really smart approach.
I know nothing of data modelling. Can you explain in words of two
syllables or fewer why this is so bad ? And explain what you think is
the right approach ?
--
Michael C. Harris, School of CS&IT, RMIT University
http://twofishcreative.com/michael/blog
IRC: michaeltwofish #habari
The DB should be considered a raw data store-house. I'm not some leet
developer, or a massively programatically knowledgeable sod, so let me
put it in the terms that may best illustrate my humble point:
Consider a refrigerator - it keeps things cold and holds them in place. It
stores food in reasonably defined but flexible places.
You don't typically use a fridge to heat your food, or mix it, or fold it into
pretty shapes and serve it out for you. That takes other processes and
tools. When you keep a fridge, a fridge, it means any chef can use
anything else with it.
It remains highly compatible with pretty much any other kitchen tool or
appliance- and, most importantly, remains highly efficient.
When you start building many things into the fridge, or make up rules
about what can go in the fridge, how the fridge should store it, etc - the
bottleneck and feature set becomes all about _the fridge_. Not the chef.
Or his recipes. Or even the kitchen.
If the fridge then starts to become overloaded with tasks, it will eventually
start to fail in doing what it does best. Acting as simple, reliable storage.
My point?
The DB should be just a store. When you start using the DB engine for
computational work, rather than outright in/ out processing, it will slow
the hell down.
Just because you can query every record with * over a 5 million row table,
doesn't mean you should. Sometimes, less is more. Less is also much
much faster. And as we all know - the single worst thing is a slow
DB engine.
Everything _else_ falls apart as a result. The DB is key. Thus the fridge
is important.
So keeping data like dates as generic as well as cross-db-independant
as possible is going to mean Habari doesn't fall down the same endless
pit Wordpress has.
This is a long post. My appologies on that, but Habari is at the point
now where it can have all manner of 'features' that will absolutely KILL
DB performance.
It's critical that, where possible, data (outside of post content, perhaps)
is stored in as simple, un-processed state as possible.
Most web server engines have more than enough features and grunt,
along with PHP, to generate all sorts of content. Keep the load where
it can be scaled and leave the DB to be the fridge. :)
[Is this where I get kicked out for too-many-words illness? :)]
Cheers,
Brendan.
[cleans the fridge]
> [Is this where I get kicked out for too-many-words illness? :)]
No, stop worrying.
http://wiki.habariproject.org/en/API/overview