Udf Oddities

I have been experiencing some wierd udf behaviour.
I have a udf that takes 7.5 mins to run.  The sql inside the udf runs in < 1s.
Run the query under index tuning wizard and it suggests a very odd index.
Adding the index gets the time for both down to < 1s.

I have a second udf that is not as condusive to the index tuning wizard.

 

Dynamic Type Loading

Here is a very simple sample of dynamic type loading:

==== LoadLibrary.cs ==== 

using System;
using System.Reflection;

namespace LoadLibrary
{
    class Program
    {
        static void Main(string[] args)
        {
            Assembly ass = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory
                + @”.SimpleLib.dll”);
            Type type = ass.GetType(“SimpleLib.SimpleClass”);
            object newInstance = Activator.CreateInstance(type);
            Console.WriteLine(newInstance);
            Console.ReadLine();
        }
    }
}

=== SimpleClass.cs ===

namespace SimpleLib
{
    public class SimpleClass
    {
        public override string ToString()
        {
            return “I am a simple class”;
        }
    }
}

 

Build simple class into SimpleLib.dll

Build LoadLibrary into LoadLibrary.exe

Put SimpleLib.dll into the same directory as LoadLibrary.

 

Lightweight Ruby Webserver to list podcasts

Once you get your head around ruby constructs the following was easy to write:

As a benefit it actually displays properly…

require ‘socket’

def latest3podcasts(session, podcast)
session.print “


  • Dir.glob(podcast)[-3..-1].each {|x| session.print “
  • #{x}
  • ” }
    session.print “

rn”
end

port = 8080.to_i
server = TCPServer.new(‘serveraddress’,port)
while (session = server.accept)
puts “Request: #{session.gets}”
session.print “HTTP/1.1 200/OKrnContent-type: text/htmlrnrn”
session.print “”
latest3podcasts(session, “/storage/podcast/dotnetrocks/*.mp3”)
latest3podcasts(session, “/storage/podcast/hanselminutes/*.mp3”)
latest3podcasts(session, “/storage/podcast/polymorphicpodcast/*.mp3”)
session.print “rn”
session.close
end