Re: Where are the detoast function called in select * from table_name case?

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Where are the detoast function called in select * from table_name case?
Дата
Msg-id 554A134C.1060507@iki.fi
обсуждение исходный текст
Ответ на Where are the detoast function called in select * from table_name case?  (Rui Hai Jiang <ruihaijiang@msn.com>)
Список pgsql-hackers
On 05/06/2015 04:00 PM, Rui Hai Jiang wrote:
> I've been reading the PostgreSQL code for weeks to figure out how TOAST
> works.
> I couldn't find where are the TOAST function called to detoast a tuple
> comes from a select query, for example, select * from table_name.
> Does anyone know this? Can you give me some help? And any help would
> save me a lot of time.

The tuple isn't detoasted immediately when it's read. Individual datums 
of the tuple are detoasted lazily, when needed, in whatever function 
it's passed to. If you just do "select * from table", the first function 
it's passed to is the datatype's output function, so that detoasts it. 
For example, if it's a text column, the toasted Datum is passed to 
textout(), which calls text_to_cstring(). text_to_cstring() calls 
pg_detoast_datum_packed(), which finally detoasts it.

You can launch a debugger on the backend process, and put a breakpoint 
on e.g. heap_tuple_untoast_attr() to see it in action.

- Heikki



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

Предыдущее
От: Rui Hai Jiang
Дата:
Сообщение: Where are the detoast function called in select * from table_name case?
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: is possible to upgrade from 9.2 to 9.4 with pg_upgrade