# |
Aug 22nd 2019, 10:48 |
steinkel |
@conehead why using left join on count? it's not going to affect the number of rows... try `SELECT COUNT(id) AS `documentsCount` FROM documents Documents` |
# |
Aug 22nd 2019, 10:45 |
spriz |
maybe time to go to offset based pagination :slightly_smiling_face: |
# |
Aug 22nd 2019, 10:45 |
spriz |
`count(*)` is tought one |
# |
Aug 22nd 2019, 10:44 |
conehead |
Yes, model and foreign key are combined a unique key now. And it boosted performance for the simple queries...but not for pagination ;D |
# |
Aug 22nd 2019, 10:43 |
neon1024 |
Does `Status.model` have an index? Although I’m guessing now. We’ve moved beyond my level of expertise :P |
# |
Aug 22nd 2019, 10:42 |
conehead |
``` SELECT ( COUNT(*) ) AS `count` FROM documents Documents LEFT JOIN statuses Status ON ( Status.model = 'Documents' AND Documents.id = (Status.foreign_key) ) ``` Well I will have a look |
# |
Aug 22nd 2019, 10:41 |
conehead |
It is a quiet simple one... |
# |
Aug 22nd 2019, 10:40 |
neon1024 |
Perhaps it’s time to profile the queyr |
# |
Aug 22nd 2019, 10:39 |
conehead |
Confusing....looks like a simple count SQL takes 26 seconds |
# |
Aug 22nd 2019, 10:36 |
conehead |
Wanna paginate with datatables |
# |
Aug 22nd 2019, 10:36 |
conehead |
No I need more later. Just for testing now 1 item |
# |
Aug 22nd 2019, 10:35 |
neon1024 |
Or, are you doing like a paginated view? Where you view a single document per page? |
# |
Aug 22nd 2019, 10:35 |
neon1024 |
That strikes me as an odd query to do. If you want a single document, would you not find it by id? Or is this an example where you’ve reduced it to 1 item to test? |
# |
Aug 22nd 2019, 10:29 |
conehead |
@neon1024 Yes, pretty much lots of rows. But I only need to get one `Document` with it's `Status`. Currently there are roughly 6k documents and 8k statuses. This here results in a timeout: ``` $this->paginate = [ 'limit' => 1, 'contain' => [ 'Status', ], ]; $pag = $this->paginate($this->Documents->find()); ``` |
# |
Aug 22nd 2019, 10:24 |
neon1024 |
@ndm Nor me :man-shrugging: It might just be my brain, or my bad code. I’ve historically always had issues with this part of the framework |
# |
Aug 22nd 2019, 10:24 |
neon1024 |
Perhaps that combined with the joins is slowing things down? Perhaps it’s worth experimenting with an offset paginator |
# |
Aug 22nd 2019, 10:24 |
ndm |
@neon1024 I don't really see how that could possibly happen, unless maybe the request object is modified somewhere. |
# |
Aug 22nd 2019, 10:23 |
neon1024 |
@conehead Do you have lots of rows? Cake uses limit pagination by default, so it’ll load the entire result set and sub-set for the page |
# |
Aug 22nd 2019, 10:22 |
conehead |
Hm neon my problem is actually not really solved with the missing index. When just executing the query the result comes really fast. When passing this query to a paginator, I get timeouts again. The (hasOne) relations that slow everything down have a condition |
# |
Aug 22nd 2019, 10:20 |
neon1024 |
Needs work imho |
# |
Aug 22nd 2019, 10:19 |
neon1024 |
RIP CSRF Middleware |
# |
Aug 22nd 2019, 10:19 |
neon1024 |
Lol, even the whitelist callback doesn’t work |
# |
Aug 22nd 2019, 10:17 |
neon1024 |
Yep |
# |
Aug 22nd 2019, 10:16 |
ndm |
You mean the paramter in the request object is empty? |
# |
Aug 22nd 2019, 10:13 |
neon1024 |
I’ll use the whitelist callback |
# |
Aug 22nd 2019, 10:13 |
neon1024 |
So when I hit this page, my `_csrfToken` is empty |
# |
Aug 22nd 2019, 10:13 |
ndm |
I'm not overly familiar with Vue.js, but I don't see how adding a script tag on top wouldn't work |
# |
Aug 22nd 2019, 10:11 |
neon1024 |
This is my template |
# |
Aug 22nd 2019, 10:11 |
slackebot2 |
<neon1024> |
# |
Aug 22nd 2019, 10:10 |
neon1024 |
I’m using Vue.js to build a component which manages the whole template |
# |
Aug 22nd 2019, 10:10 |
ndm |
what does "rendering javascript" mean |
# |
Aug 22nd 2019, 10:10 |
neon1024 |
I think I’ll just turn off CSRF for this prefix |
# |
Aug 22nd 2019, 10:09 |
neon1024 |
Seems to work on other pages |
# |
Aug 22nd 2019, 10:09 |
neon1024 |
Adding the token to the layout doesn’t work when I’m redering my javascript |
# |
Aug 22nd 2019, 10:09 |
challgren |
Ahh ok |
# |
Aug 22nd 2019, 10:09 |
ndm |
@challgren Oh wait, I think I misunderstood you... the cookie would be there. Still I think passing the value to JS is cleaner, no need to parse the cookie string, and to make the cookie insecure |
# |
Aug 22nd 2019, 10:09 |
hippo |
``` $this->enableCsrfToken(); $this->enableSecurityToken(); ``` |
# |
Aug 22nd 2019, 10:08 |
challgren |
Is there anyway to explicitly turn it on? |
# |
Aug 22nd 2019, 10:08 |
hippo |
Yes |
# |
Aug 22nd 2019, 10:08 |
challgren |
Ok so heres a question when doing Integration Testing isn’t the CSRF token check disabled? |
# |
Aug 22nd 2019, 10:03 |
ndm |
You could if it's not HTTP only, but on the first request there will be no cookie |