def get_named_cursor():
"""
This function returns a named cursor, which speeds up queries
returning large result sets immensely by caching them on the
server side.
This is not yet supported by Django itself.
"""
# This is required to populate the connection object properly
if connection.connection is None:
connection.cursor()
# Prefixing the name to ensure that it starts with a letter.
# Needed for psycopg2.2 compatibility
name = 'nav{0}'.format(str(uuid.uuid4()).replace('-', ''))
cursor = connection.connection.cursor(name=name)
return cursor
评论列表
文章目录