Re: How to delete few elements from array beginning?

Поиск
Список
Период
Сортировка
От Mike Sofen
Тема Re: How to delete few elements from array beginning?
Дата
Msg-id 022601d17a09$76414b60$62c3e220$@runbox.com
обсуждение исходный текст
Ответ на How to delete few elements from array beginning?  (Alexander Farber <alexander.farber@gmail.com>)
Ответы Re: How to delete few elements from array beginning?  (Alexander Farber <alexander.farber@gmail.com>)
Список pgsql-general

>>Alexander Farber wrote on  Wednesday, March 09, 2016 4:11 AM

Hello fellow PostgreSQL users,

what is please the most efficient way to delete a slice from the start of a longer array (after I have copied it to another array)?

Do I really have to copy a large slice of the array to itself, like in the last line here:

        pile_array := pile_array || swap_array;

        /* here I copy away swap_len elements */
        new_hand := pile_array[1:swap_len];

        /* here I don't know how to efficiently remove already copied elements */
        pile_array := pile_array[(swap_len + 1):ARRAY_LENGTH(pile_array, 1)];

or is there a better way?

Thank you

Alex

<< 

Have you considered a normal (relational), non-array-based data model for this app (2 or 3 tables in a 1:M/M:M) instead of the single table model you’ve shown?  That would then allow you to use normal sql set-based operations that are readable, understandable, maintainable and very fast/scalable. 

When I see row by row operations (looping or cursors) in what should be a real time query…that’s my alarm bell that perhaps the code has wandered off a valid solution path.

Mike

В списке pgsql-general по дате отправления:

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: regarding table migration from sql to postgres with runmtk.sh
Следующее
От: Raghavendra
Дата:
Сообщение: Re: regarding table migration from sql to postgres with runmtk.sh