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:
parent
fc3849b8be
commit
ca8ae5cd82
|
@ -417,20 +417,19 @@ class User( Persistent ):
|
||||||
def sql_calculate_storage( self, database_backend ):
|
def sql_calculate_storage( self, database_backend ):
|
||||||
"""
|
"""
|
||||||
Return a SQL string to calculate the total bytes of storage usage by this user. This includes
|
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.
|
not include storage for the notebooks themselves.
|
||||||
"""
|
"""
|
||||||
if database_backend == Persistent.POSTGRESQL_BACKEND:
|
if database_backend == Persistent.POSTGRESQL_BACKEND:
|
||||||
# this counts bytes for the contents of each column
|
# 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:
|
else:
|
||||||
# this isn't perfect, because length() counts UTF-8 characters instead of bytes.
|
# 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
|
# some columns are left out because they can be null, which screws up the addition
|
||||||
note_size_clause = \
|
note_size_clause = \
|
||||||
"""
|
"""
|
||||||
length( note_current.id ) + length( note_current.revision ) + length( note_current.title ) +
|
length( note.id ) + length( note.revision ) + length( note.title ) + length( note.contents ) +
|
||||||
length( note_current.contents ) + length( note_current.notebook_id ) +
|
length( note.notebook_id ) + length( note.startup ) + length( note.user_id )
|
||||||
length( note_current.startup ) + length( note_current.user_id )
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return \
|
return \
|
||||||
|
@ -439,11 +438,11 @@ class User( Persistent ):
|
||||||
select
|
select
|
||||||
coalesce( sum( %s ), 0 )
|
coalesce( sum( %s ), 0 )
|
||||||
from
|
from
|
||||||
user_notebook, note_current
|
user_notebook, note
|
||||||
where
|
where
|
||||||
user_notebook.user_id = %s and
|
user_notebook.user_id = %s and
|
||||||
user_notebook.owner = 't' and
|
user_notebook.owner = 't' and
|
||||||
note_current.notebook_id = user_notebook.notebook_id
|
note.notebook_id = user_notebook.notebook_id
|
||||||
) as note_storage,
|
) as note_storage,
|
||||||
(
|
(
|
||||||
select
|
select
|
||||||
|
|
Reference in New Issue
Block a user