i added some filters and im using query json with sql
SELECT * FROM {{formatDataAsArray(clientes.data)}} WHERE
({{!sector.value}} /* si esta en blanco muestra todo /
OR Sector = {{ sector.value }}) / filtro por colaborador */
AND ({{ !cedula.value }}
OR cedula ILIKE {{ cedula.value }})
AND ({{ !ubicacion.value }}
OR Ubicacion ILIKE {{ ubicacion.value }})
AND ({{ !(rangodefecha.value.start) }}
OR (fechadeseguimiento <= {{moment(rangodefecha.value.end).format('YYYY-MM-DD')}}
AND fechadeseguimiento >= {{moment(rangodefecha.value.start).format('YYYY-MM-DD')}} ))
order by fechadeseguimiento asc
but now my issue if i try to filter some data out of the current pagination it cant be found, what i should use to fix this? or should i dont usee pagination server side at all?
Is it possible that you're missing wildcards from your ILIKE statements? How do things work if you use cedula ILIKE {{ '%' + cedula.value + '%' }}) and Ubicacion ILIKE {{ '%' + ubicacion.value + '%' }})?
like that it only shows results on first page, if i go to page 2, wont work, when server side pagination is enabled i cant filter all data only the paginated page
In that case, you'll need to include the filters in the first table query since it's the only one that has access to all your data. The single page of data is all the Query JSON with SQL query has access to filter on.
Does something like this work?
SELECT
*,
DATE_PART(
'YEAR',
AGE (CURRENT_DATE, tbl_clientes.fechadenacimiento)
) AS edadFROMtbl_clientes
WHERE
(
{{!sector.value}}
OR Sector = {{ sector.value }}
)
AND (
{{ !cedula.value }}
OR cedula ILIKE {{ '%' + cedula.value + '%' }}
)
AND (
{{ !ubicacion.value }}
OR Ubicacion ILIKE {{ '%' + ubicacion.value + '%' }}
)
AND (
{{ !(rangodefecha.value.start) }}
OR (
fechadeseguimiento <= {{moment(rangodefecha.value.end).format('YYYY-MM-DD')}}
AND fechadeseguimiento >= {{moment(rangodefecha.value.start).format('YYYY-MM-DD')}}
)
)
ORDER BY
fechadeseguimiento ASC
LIMIT
{{ table1.pagination.pageSize }}
OFFSET
{{ table1.pagination.offset }}
Loom | Free Screen & Video Recording Software | Loom this is what im getting, i stopped using query json with sql and put the main query as you said. if you see the result is on the page 2 that ID number, but when i try to search it in page #2 it wont work, but if i move to page #1, it works. What im doing wrong?
It doesn't look like you need it here but filtering with a server-side paginated query can be tricky since your table will stay on the same page even when the query is rerun. Can you try adding an event handler to your input component that sets the table back to its first page?
will try that, but thats the correct approach for me use case? what you think? basically its a table with a query that have inner join in total i have 130k records, and users will be updating, adding, deleting in those tables in the day, there will be 10 users at the same time i need the best perfomance possible
@Kabirdas but if server side is tricky any chance i can use redis or dozer as cache for postgresql? i dont know if someone else in here got the same use case, a table with a large dataset and custom filters and the need to lookup all dataset not only first page im struggling
You could potentially try client-side pagination and see how performant it is @agaitan026. 100k records is certainly a lot to pull in at once but the new table is much better equipped to handle large collections of data. From there you could decide if the tradeoffs in performance are worth it for one method or the other
Yeah what i did was to use filters directly in postgresql not using query sql with json as that only filter page 1. Also i added all my filters to the rowcount query too and worked good. Still not sure if doing the setpage 1 thing is something good or not. Not sure about that
If you were to pull in the full data set with your original query you could filter the results using a Query JSON with SQL query and then use client-side pagination in the table settings instead of trying to do it in the Query JSON with SQL query.
I don’t understand, so i need to add all where statement for filter in original query. Then the query json with sql what will do? Any performance gain with that?
Right now i got
Original query with all filter using limit and offset to use server side pagination