witten
/
luminotes
Archived
1
0
Fork 0

Rolling back the part of revision 1285 that made quota calculation just use note_current instead of note table.

It was intended to make quota storage calculation faster, which it did
do. However, it wasn't enough of an improvement (27 seconds down to 8
seconds for the query), so a different solution will be necessary.
This commit is contained in:
Dan Helfman 2008-11-21 16:17:54 -08:00
parent fc3849b8be
commit ca8ae5cd82
1 changed files with 6 additions and 7 deletions

View File

@ -417,20 +417,19 @@ class User( Persistent ):
def sql_calculate_storage( self, database_backend ):
"""
Return a SQL string to calculate the total bytes of storage usage by this user. This includes
storage for all the user's notes (excluding past revisions) and their uploaded files. It does
storage for all the user's notes (including past revisions) and their uploaded files. It does
not include storage for the notebooks themselves.
"""
if database_backend == Persistent.POSTGRESQL_BACKEND:
# this counts bytes for the contents of each column
note_size_clause = "pg_column_size( note_current.* )"
note_size_clause = "pg_column_size( note.* )"
else:
# this isn't perfect, because length() counts UTF-8 characters instead of bytes.
# some columns are left out because they can be null, which screws up the addition
note_size_clause = \
"""
length( note_current.id ) + length( note_current.revision ) + length( note_current.title ) +
length( note_current.contents ) + length( note_current.notebook_id ) +
length( note_current.startup ) + length( note_current.user_id )
length( note.id ) + length( note.revision ) + length( note.title ) + length( note.contents ) +
length( note.notebook_id ) + length( note.startup ) + length( note.user_id )
"""
return \
@ -439,11 +438,11 @@ class User( Persistent ):
select
coalesce( sum( %s ), 0 )
from
user_notebook, note_current
user_notebook, note
where
user_notebook.user_id = %s and
user_notebook.owner = 't' and
note_current.notebook_id = user_notebook.notebook_id
note.notebook_id = user_notebook.notebook_id
) as note_storage,
(
select