delayed input

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hicham G. Elmongui

    delayed input

    I need to select all tuples from a table, but need them to be fetched with a
    constant delay (say 1 sec) between every consecutive tuples.

    The first idea that came up to my mind is to create a DelayedSeqScan
    operator, and put delay before returning the scanned tuple.

    Can I do this functionality using table functions?

    Regards,
    --h


  • Kevin Barnard

    #2
    Re: delayed input

    Why not do this on the client side? I'm just curious as to the benfit
    of doing this on the server.

    On Tue, 19 Oct 2004 11:10:58 -0500, Hicham G. Elmongui
    <elmongui@cs.pu rdue.edu> wrote:[color=blue]
    > I need to select all tuples from a table, but need them to be fetched with a
    > constant delay (say 1 sec) between every consecutive tuples.
    >
    > The first idea that came up to my mind is to create a DelayedSeqScan
    > operator, and put delay before returning the scanned tuple.
    >
    > Can I do this functionality using table functions?
    >
    > Regards,
    > --h[/color]

    ---------------------------(end of broadcast)---------------------------
    TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddres sHere" to majordomo@postg resql.org)

    Comment

    • Richard Huxton

      #3
      Re: delayed input

      Hicham G. Elmongui wrote:[color=blue]
      > I need to select all tuples from a table, but need them to be fetched with a
      > constant delay (say 1 sec) between every consecutive tuples.
      >
      > The first idea that came up to my mind is to create a DelayedSeqScan
      > operator, and put delay before returning the scanned tuple.
      >
      > Can I do this functionality using table functions?[/color]

      Could you not just use a cursor and fetch each row in turn based on some
      timer in your application?

      --
      Richard Huxton
      Archonet Ltd

      ---------------------------(end of broadcast)---------------------------
      TIP 2: you can get off all lists at once with the unregister command
      (send "unregister YourEmailAddres sHere" to majordomo@postg resql.org)

      Comment

      • Pierre-Frédéric Caillaud

        #4
        Re: delayed input



        Use a cursor...
        [color=blue]
        > I need to select all tuples from a table, but need them to be fetched
        > with a
        > constant delay (say 1 sec) between every consecutive tuples.
        >
        > The first idea that came up to my mind is to create a DelayedSeqScan
        > operator, and put delay before returning the scanned tuple.
        >
        > Can I do this functionality using table functions?
        >
        > Regards,
        > --h
        >
        >
        >
        > ---------------------------(end of broadcast)---------------------------
        > TIP 5: Have you checked our extensive FAQ?
        >
        > http://www.postgresql.org/docs/faqs/FAQ.html
        >[/color]



        ---------------------------(end of broadcast)---------------------------
        TIP 3: if posting/reading through Usenet, please send an appropriate
        subscribe-nomail command to majordomo@postg resql.org so that your
        message can get through to the mailing list cleanly

        Comment

        • Hicham G. Elmongui

          #5
          Re: delayed input

          I need this for a side project. Is there a way to do something like this:

          SELECT *
          FROM DelayedTable('t ablename', 5);

          DelayedTable provides me with one tuple every 5 seconds.
          Regards,
          --h

          "Hicham G. Elmongui" <elmongui@cs.pu rdue.edu> wrote in message
          news:cl3eaj$1gg v$1@news.hub.or g...[color=blue]
          > I need to select all tuples from a table, but need them to be fetched with[/color]
          a[color=blue]
          > constant delay (say 1 sec) between every consecutive tuples.
          >
          > The first idea that came up to my mind is to create a DelayedSeqScan
          > operator, and put delay before returning the scanned tuple.
          >
          > Can I do this functionality using table functions?
          >
          > Regards,
          > --h
          >
          >[/color]


          Comment

          • Gaetano Mendola

            #6
            Re: delayed input

            Hicham G. Elmongui wrote:[color=blue]
            > I need this for a side project. Is there a way to do something like this:
            >
            > SELECT *
            > FROM DelayedTable('t ablename', 5);[/color]

            No, at my knowledge you'll obtain the first tuple only when
            the function exit.


            Regards
            Gaetano Mendola



            Comment

            • Alvaro Herrera

              #7
              Re: delayed input

              On Tue, Oct 19, 2004 at 01:44:34PM -0500, Hicham G. Elmongui wrote:[color=blue]
              > I need this for a side project. Is there a way to do something like this:
              >
              > SELECT *
              > FROM DelayedTable('t ablename', 5);[/color]

              You can probably build a sleep() function in C, and then use that to
              cause delaying in a PL/pgSQL set-returning function. Something like

              #include <postgres.h>
              #include <fmgr.h>

              PG_FUNCTION_INF O_V1(sleep);

              Datum
              sleep(PG_FUNCTI ON_ARGS)
              {
              int32 delay = PG_GETARG_INT32 (0);
              sleep(delay);
              PG_RETURN_VOID( );
              }

              --
              Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
              La web junta la gente porque no importa que clase de mutante sexual seas,
              tienes millones de posibles parejas. Pon "buscar gente que tengan sexo con
              ciervos incendiándose", y el computador dirá "especifiqu e el tipo de ciervo"
              (Jason Alexander)


              ---------------------------(end of broadcast)---------------------------
              TIP 6: Have you searched our list archives?



              Comment

              • Hicham G. Elmongui

                #8
                Re: delayed input

                Well, it seems that i have to build the scan operator myself. Even the
                FunctionScan will make all the function calls and stores the result in a
                tuuplestore. So, all the delay will be occured only at the first function
                invocation.
                --h




                "Alvaro Herrera" <alvherre@dcc.u chile.cl> wrote in message
                news:2004101919 1943.GC5625@dcc .uchile.cl...[color=blue]
                > On Tue, Oct 19, 2004 at 01:44:34PM -0500, Hicham G. Elmongui wrote:[color=green]
                > > I need this for a side project. Is there a way to do something like[/color][/color]
                this:[color=blue][color=green]
                > >
                > > SELECT *
                > > FROM DelayedTable('t ablename', 5);[/color]
                >
                > You can probably build a sleep() function in C, and then use that to
                > cause delaying in a PL/pgSQL set-returning function. Something like
                >
                > #include <postgres.h>
                > #include <fmgr.h>
                >
                > PG_FUNCTION_INF O_V1(sleep);
                >
                > Datum
                > sleep(PG_FUNCTI ON_ARGS)
                > {
                > int32 delay = PG_GETARG_INT32 (0);
                > sleep(delay);
                > PG_RETURN_VOID( );
                > }
                >
                > --
                > Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
                > La web junta la gente porque no importa que clase de mutante sexual seas,
                > tienes millones de posibles parejas. Pon "buscar gente que tengan sexo con
                > ciervos incendiándose", y el computador dirá "especifiqu e el tipo de[/color]
                ciervo"[color=blue]
                > (Jason Alexander)
                >
                >
                > ---------------------------(end of broadcast)---------------------------
                > TIP 6: Have you searched our list archives?
                >
                > http://archives.postgresql.org
                >[/color]


                Comment

                Working...