Re: Web + Slicing/Paging datas
От | durumdara |
---|---|
Тема | Re: Web + Slicing/Paging datas |
Дата | |
Msg-id | 49F0328F.2040206@gmail.com обсуждение исходный текст |
Ответ на | Re: Web + Slicing/Paging datas (John R Pierce <pierce@hogranch.com>) |
Список | pgsql-general |
Hi! 2009.04.23. 9:23 keltezéssel, John R Pierce írta: > durumdara wrote: >> Hi! >> >> In a mod_py application I wanna write a wrapper that handle all PSQL >> data view with paging/slicing. >> >> .. >> Inserts all records to a temp table. >> Check the affected rows (as count). >> Slicing the records. >> Fetch the slice records. >> Destroy temp table. > > > how about KEEPING the data in this slice format, and keeping the count > somewhere ? you'd need to update the count and slice info when new > data gets added, but perhaps thats better than doing it every time you > want to view a slice? > > This is a complicated thing. These datas are provided by a query, with some user's conditions. For example: Text = Free String Search Live = This data is living Category = Some category SubCategory = Some subcategory ... etc. So your way is possible working with this pseudo code: def Slicing(PageIndex, Conditions): # Del recs that have older than 30 minutes delsql = "delete from pagingtable where inserted < %s" % IncWithMinutes(Now, -30) ExecSQL(delsql) # The Query datasql = BuildSQL(Conditions) # Have same query in the pool? checksql = "select count from pagingtable where sql='%s'" % SafeEscape(datasql) records = ExecSQL(checksql) if records: # Yes count = records[0]['COUNT'] else: # No, we must run a count sql to check countsql = BuildSQL(Conditions, Count = 1) datarecords = ExecSQL(countsql) datarecord = datarecords[0] count = datarecord['COUNT'] # We must insert it to the paging table InsertPagingRecord(datasql, count) ... # Use the count ... finalsql = BuildSQL(Conditions, WithPaging = PageIndex) finalrecords = ExecSQL(finalsql) ... But possible it is too complex and I fear that it cause more pain than I winning in it... (deadlocks?)... Thanks for your help: dd
В списке pgsql-general по дате отправления: