[Zope3-dev] Re: I want Object Gadfly

Stuart Bishop zen@shangri-la.dropbear.id.au
Sat, 19 Jul 2003 14:32:23 +1000


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Saturday, July 19, 2003, at 05:57  AM, Paul Winkler wrote:

> On Fri, Jul 18, 2003 at 02:39:22PM -0400, Jim Fulton wrote:
>>> Should queries
>>> have access to the referenced object directly, or only to some kind 
>>> of
>>> referential meta-data?
>>
>> Reference to object directly.
>>
>>> In other words, is this kosher:
>>>
>>> SELECT * from user_links
>>> WHERE source.absolute_url().startswith('/articles/2003')
>>>  and source.title contains 'Gadfly';
>>
>> Yup.
>
> So every query will wake up every object referenced in the table?

I'd say so, unless an index has been created on source.absolute_url()
or source.absolute_url().startswith('/articles/2003'). This is
exactly like a normal RDB, where the query optimizer uses indexes
where sane, and falls back to full table scans when they are not.

The ugly one would be:

class Foo:
	def getNextKey():
		self._last_draft_number += 1
		return self._last_draft_number

SELECT * from whatever WHERE foo.getNextKey() > 1;

So don't do that :-) Or have the system throw a StoopidProgrammerError
if the query sets any _p_changed flags. Or run the query in a 
subtransaction
that is rolled back after we have got the results.

- -- 
Stuart Bishop <zen@shangri-la.dropbear.id.au>
http://shangri-la.dropbear.id.au/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (Darwin)

iD8DBQE/GMndh8iUz1x5geARAoBUAKCIuT5vAAN+v5jqFvFaF8BajLROZwCgsZur
TnDTfcn+BBT2BsJs9Abcu34=
=o2IW
-----END PGP SIGNATURE-----