On Tue, 2003-12-30 at 06:46, Steve O'Hara wrote: > My understanding is that logically, by their very nature, joins are always > likely to be slower than single table queries - I thought that this was a > given downside to normalisation or am I incorrect? Maybe the downside is > not pronounced in SQLite but I'm sure that you see it in other RDBMS (if you > crank up the results set volume enough).
Not necessarily; JOIN is an algebraic operation. Most RDBMS can handle JOINs efficiently - especially with the aid of indexes. Some RDBMS even translate "multi-occurrence columns" into JOIN operations transparently. Some database engines cannot optimize all forms of JOIN, nor can they optimize all syntax for a join, but these are deficiencies in the database engine, not in SQL itself. > > > > If you think this is easier to read, then consider creating VIEWs > > > > to > > > > store intermediate queries. > > > > > > I have never considered this as I am not a power user of SQLite. > > > Sorry...! > > > > VIEWs are quite normal in other SQL providers. That said, you may want > > to become more familiar with SQL before you start suggesting extensions > > to it- at the very least, be aware that syntactical additions may very > > well be fine, but you will face criticism if your reasoning is flawed. > > > > In SQLite, VIEWs are simply an expedient for expressing your query - there > is no performance upside to using them opposed to a fully specified SQL > command. Agreed. They were covered because another reason for the "new syntax" was because they're "easier to read" (something I happen to disagree with). > > If you have a table which has a value that can return multiple values > > you MUST alter the API of the callback function or of the fetch > > function. Otherwise how is older code supposed to deal with a table > > having multiple values in an attribute? > > > > Why? > Most systems will return you the whole column value with delimiter > character(s) separating the sub-fields. > I think the alterations to the API will not be in the callback at all, but > WILL be in the query processor and index engine. > We are talking about changing the search engine to delineate certain field > values when querying. It's easier for the indexer, which simply creates > multiple postings for the same record but with different terms (each > sub-field). No, we weren't talking about that. That's one solution that I suggested (using a user-defined function to split out various portions of the value). We were talking about adding new syntax to SQL(ite) that performs implicit joins making it possible to return and store multiple _values_ within a single column/row. > I fully understand your point about normalisation and fully understanding > issues before pronouncing on them. > However, I think that your not seeing the full picture of the usefulness of > multi-occurance columns with the simple example mentioned previously. .... > Take a trivial names and address scenario - each person can have multiple > addresses, phone numbers, emails, fax numbers. > In a normalised world where we have a table for each of these, you soon run > into a complicated query if you want to find a person who has a particular > address, a particular phone number, a particular email etc. Don't we have > to do unions of a number of joins? > Whereas, in a multi-occurrence schema it's simply > select * from names where address='vghg' and phone='776' and email='jhjh' > etc. and how is the callback called for each _phone_ where: select * from names where address='yghg'; How many times is callback called? for which rows? How do we tell which inner-structure we are in? Is the callback going to get a folded string? an incomplete one? or just some dummy blob to be passed to another sqlite function? These are very important questions that _must_ be resolved. If they aren't- then compatibility is broken. Thus I suggested moving it entirely into functions, that is: select * from names where any_equals('address','yghg'); where any_equals() is a function that splits/checks values as appropriate. besides not making any changes to the callback API, this method is future proof, although as you might have noticed, it cannot presently take advantage of indexes (sqlite doesn't presently index functions, IIRC). if the question is simple enough- and all your operations are like any_equals() you can optimize this to use the LIKE operator which doesn't require any new functions AND can utilize indexes (my other suggestion). --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]