Re: [HACKERS] jsonb access operators inefficiency

2014-06-01 Thread Andrew Dunstan
On 05/30/2014 01:41 PM, Tom Lane wrote: Andrew Dunstan and...@dunslane.net writes: If we're going to construct varlena objects inside a StringInfo, maybe we need a proper API for it. Isn't there a danger that data member of the StringInfo won't be properly aligned to allow us to do this? In

Re: [HACKERS] jsonb access operators inefficiency

2014-05-30 Thread Andrew Dunstan
On 05/30/2014 09:35 AM, Teodor Sigaev wrote: Hi! jsonb operators -text, -text,-int, -int use inefficient methods to access to needed field, proportional O(N/2). Attached patch suggests for text operators O(log(N)) and for integer - O(1). The fuctions with fast access already are existed in

Re: [HACKERS] jsonb access operators inefficiency

2014-05-30 Thread Andrew Dunstan
On 05/30/2014 11:08 AM, Andrew Dunstan wrote: On 05/30/2014 09:35 AM, Teodor Sigaev wrote: Hi! jsonb operators -text, -text,-int, -int use inefficient methods to access to needed field, proportional O(N/2). Attached patch suggests for text operators O(log(N)) and for integer - O(1). The

Re: [HACKERS] jsonb access operators inefficiency

2014-05-30 Thread Teodor Sigaev
If we're going to construct varlena objects inside a StringInfo, maybe we need a proper API for it. Isn't there a danger that data member of the StringInfo won't be properly aligned to allow us to do this? In any case, we should get most of the benefit of your patch without this optimization.

Re: [HACKERS] jsonb access operators inefficiency

2014-05-30 Thread Teodor Sigaev
I see that palloc.h says: The result of palloc() is always word-aligned void * repalloc(void *pointer, Size size) { ... /* * Try to detect bogus pointers handed to us, poorly though we can. * Presumably, a pointer that isn't MAXALIGNED isn't pointing at an * allocated

Re: [HACKERS] jsonb access operators inefficiency

2014-05-30 Thread Oleg Bartunov
The patch really improves access performance to jsonb. On the delicious bookmarks I got 5 times better performance.Now jsonb outperforms json on simple access (slide 12 of pgcon presentation) by 103 times ! Oleg On Fri, May 30, 2014 at 9:35 AM, Teodor Sigaev teo...@sigaev.ru wrote: Hi!

Re: [HACKERS] jsonb access operators inefficiency

2014-05-30 Thread Andrew Dunstan
On 05/30/2014 01:30 PM, Oleg Bartunov wrote: The patch really improves access performance to jsonb. On the delicious bookmarks I got 5 times better performance.Now jsonb outperforms json on simple access (slide 12 of pgcon presentation) by 103 times ! (Oleg, please try not to top-post)

Re: [HACKERS] jsonb access operators inefficiency

2014-05-30 Thread Tom Lane
Andrew Dunstan and...@dunslane.net writes: If we're going to construct varlena objects inside a StringInfo, maybe we need a proper API for it. Isn't there a danger that data member of the StringInfo won't be properly aligned to allow us to do this? In any case, we should get most of the

Re: [HACKERS] jsonb access operators inefficiency

2014-05-30 Thread Teodor Sigaev
The question is whether the speedup comes from the reduction in lookup times or the reduction in string copying. I have a strong suspicion that it's mostly the first, not the second. Agree with about Oleg's test, but some users put huge values into json... Actually, I don't insist, ITSM,