hello everyone, I need to cache a data sample extracted from a large table at regular time intervals but due to poor performance I don't want to use :
db().select(db.table_name.ALL, orderby='<random>', limit=) and the posgreSQL TABLESAMPLE functionality doesn't seem to work: code: def rowsampl(): q = "SELECT * FROM table_name TABLESAMPLE SYSTEM(0.5);" result=db.executesql(q) return locals() error: Ticket ID 127.0.0.1.2017-09-09.12-58-05.12040b96-266e-477d-aaee-8c0f9fe0755b <class 'psycopg2.ProgrammingError'> syntax error at or near "SYSTEM" LINE 1: SELECT * FROM table_name TABLESAMPLE SYSTEM(0.5); ^ Version web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback Traceback (most recent call last): File "/opt/web2py/gluon/restricted.py", line 227, in restricted exec ccode in environment File "/opt/web2py/applications/myapp/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/proximb/controllers/default.py>, line 1086, in <module> File "/opt/web2py/gluon/globals.py", line 417, in <lambda> self._caller = lambda f: f() File "/opt/web2py/applications/myapp/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/proximb/controllers/default.py>, line 693, in rowsampl result=db.executesql(q) File "/opt/web2py/gluon/packages/dal/pydal/base.py", line 1019, in executesql adapter.execute(query) File "/opt/web2py/gluon/packages/dal/pydal/adapters/postgres.py", line 362, in execute return BaseAdapter.execute(self, *a, **b) File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1388, in execute return self.log_execute(*a, **b) File "/opt/web2py/gluon/packages/dal/pydal/adapters/base.py", line 1382, in log_execute ret = self.get_cursor().execute(command, *a[1:], **b) ProgrammingError: syntax error at or near "SYSTEM" LINE 1: SELECT * FROM table_name TABLESAMPLE SYSTEM(0.5); 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. Is there an economic way to treat this ? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

